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
Getting Started with Sencha Touch Contents What is Sencha Touch? Sencha Touch enables you to quickly and easily create HTML5 based mobile apps that work on Android, iOS, and Blackberry devices, and produce a native-app-like experience inside a browser or in a hybrid shell. Prerequisites First, you need to download the free Sencha Touch SDK and Sencha Cmd from the Sencha website. You will also need the following: - A web server running locally on your computer - A modern web browser; Chrome and Safari are recommended If you are running the IIS web server on Windows, please note that you have to manually add application/x-json as a MIME Type for Sencha Touch to work properly. For information on adding this MIME type see the following link:. Installation First, extract the SDK zip file to your projects directory. Ideally, this folder will be accessible to your HTTP server. For example, you should be able to navigate to from your web browser and see the Sencha Touch documentation. You also need to run the Sencha Cmd installer. The installer adds the sencha command line tool to your path, enabling you to generate a fresh application template, among other things. To check that you have correctly installed Sencha Cmd, change to your Sencha Touch directory and type in the sencha command, as shown, for example, in the following code sample: $ cd ~/webroot/sencha-touch-2.1.0-gpl/ $ sencha Sencha Cmd v3.0.0 ... Note: When using the sencha command, you must be inside either the downloaded SDK directory or a generated Touch app. For further details see the Sencha Cmd documentation. Generating Your First App Now that you have Sencha Touch and Sencha Cmd installed, let us generate an application. While still in the Sencha Touch SDK folder, type in the following: $ sencha app create MyApp ../MyApp [INFO] Created file ... ... This generates a skeleton Sencha Touch application namespaced to the MyApp variable and located in the ../MyApp directory (one level up from the Sencha Touch SDK directory). The skeleton app contains all the files you need to create a Sencha Touch application, including the default index.html file, a copy of the Touch SDK, the CSS file, images and configuration files for creating native packages for your app. Let us verify if your application has generated successfully by opening it in a web browser. Assuming that you extracted the SDK to your webroot folder, you should be able to nativate to and see the default app as shown in the following image: Explore the Code When you open the MyApp directory in your favorite IDE or text editor, you notice that the directory structure looks like shown in the following image: The following listing provides a short description of each file and directory, the complete list of the generated files can be found in the Sencha Cmd documentation: app- The directory containing the Models, Views, Controllers, and Stores for your app. app.js- The main Javascript entry point for your app. app.json- The configuration file for your app. index.html- The HTML file for your app. packager.json- The configuration file used by Sencha Cmd for creating native packages for your application. resources- The directory containing the CSS and the images for your app sdk- A copy of the Sencha Touch SDK. Normally, you should not need to change the contents of this folder. Open app.js, the main entry point for your app, in your editor: The launch function is the entry point to your application. In the default application, we first hide the application loading indicator, then we create an instance of our Main view and add it to the Viewport. The Viewport is a Card layout to which you can add application components. The default app adds the Main view to the viewport so it becomes visible on the screen. Let us look at the code inside the Main view. Open app/view/Main.js in your code editor and edit line 10 as follows: title: 'Home Tab' then change line 19 as follows: title: 'Woohoo!' Also, change lines 22-26 as follows: html: [ "I changed the default <b>HTML Contents</b> to something different!" ].join("") Eventually refresh the app in your browser to see the effects of your changes: Next Steps The next step is to follow the First Application guide, which builds on the operations from this guide, and which guides your through creating a simple but powerful app in around 15 minutes. You can also follow along with the video at the start of this guide. If you would like to skip ahead or find out more detailed information about other aspects of the framework, we recommend referring to the following guides and resources: Guides - Components and Containers - Intro to Applications - The Layout System - The Data Package - What's New in Sencha Touch 2
http://docs.sencha.com/touch/2.1.1/?_escaped_fragment_=/guide/getting_started
CC-MAIN-2016-50
refinedweb
812
59.43
Read, recycle, and reuse: Reporting made easy with Excel, XML, and Java technologies, Part 1 Read Excel files and write them to new files using Java and XML technologies 02 Mar 2010 Added links to Part 2 in sections The sample application, Conclusion, and Related topics Creative excuse number 432: Reporting is bad for the environment. Charts and reports consume trees. Electronic versions use electricity and fossil fuels. Perhaps a company could "go green" and stop writing reports? Developing reports for senior staff can make Java programmers anxious, especially when programmers prefer developer-friendly output, such as XML, but senior management only speaks the language of GUI-assisted spreadsheets. Anxiety may increase greenhouse gas "output" by the programmers involved, especially if they start hyperventilating. Although reporting takes time and resources, it is essential for providing project visibility to upper management. Management might mistrust hard-working teams simply because the upper levels can't see what their teams are doing. So, reporting is vital for the work environment. A few Java tricks can increase a programmer's "miles per gallon" when working with reports from spreadsheet lovers. After walking through the steps of this article, an intermediate-level Java programmer should understand the basic principles behind converting data programmatically between Microsoft® Excel® and XML. Excel to Java APIs Several Java APIs manipulate Excel files. Which one is the best? It depends on your individual needs and level of experience. Andy Khan's Java Excel API Andy Khan created an API called the Java Excel API, or JExcel API (see Related topics). This open source API can read and write Excel spreadsheets. Also, because it's lightweight, it's a good choice for beginning Java developers. A handy Unified Modeling Language (UML) diagram makes it easier to use and so does the API's support community. The API also has a few disadvantages. Although it reads Microsoft Excel 95, Excel 97, Excel 2000, Excel 2002, and Excel 2003 file formats, it does not currently work with any of the newer Excel formats. It cannot create charts, graphs, or macros, and it supports only PNG files for images. The xlSQL Excel JDBC Driver Another Excel-to-Java API is the xlSQL Excel Java Database Connectivity (JDBC) driver (see Related topics), an open source API for querying Excel files as if they were databases. With it, developers treat Excel sheets like tables in a database. If you're familiar with SQL and JDBC, this might be the simplest method of retrieving data. You can also add data by using SQL insert commands. Unfortunately, the xlSQL Excel JDBC driver doesn't appear to be currently or actively supported. OpenXLS OpenXLS (see Related topics) is the open source version of a commercial product by Extentech called ExtenXLS. OpenXLS has extensive capabilities. It can programmatically modify formulas and use numerous formatting options. Unlike some of the open source products, it can work with complex objects, including named ranges, pivot tables, split frames, and charts. Also, compared to similar products, OpenXLS has more thorough upfront documentation about which features are available. Unfortunately, although the open source version supports Excel formats from 97 through 2003, only the commercial version supports Excel 2007. Apache POI Apache POI is a set of Java APIs for working with both older and newer Microsoft standard documents. In addition to working with Excel versions from 97 onward, the Apache POI can work with Microsoft Word and PowerPoint® files. You can leverage your knowledge of working with Excel files to learn more quickly how to work with these additional types of files. There is also an active community of support for the API. However, because Apache POI has so much functionality and can work with other files, it might be more than a developer trying to work with only Excel files needs to learn. This article uses the Apache POI because of its support community and rich functionality. Java XML APIs XML is a popular data format, and there are several ways to work with XML in Java technology. You can choose whichever XML API works best for your project. However, this article uses Elliotte Rusty Harold's elegant XML API called XOM. For more information about XML APIs, see Related topics. The sample application The sample application for this article starts with an Excel spreadsheet file provided by the Human Resources department of the fictional Planet Power corporation. The spreadsheet is called Employee_List.xls. This article demonstrates how to use Java technology and the Apache POI to read from Employee_List.xls. The Java class file for the demonstration is ExcelReader.java and is included inside an Eclipse project. Download the .zip file containing the sample spreadsheet and Eclipse project in Downloadable resources. A Readme.txt file in the Eclipse project explains additional sample code included in the download. Part 2 of this article series will demonstrate how to convert the information to XML and create a new spreadsheet with a few modifications to the original data. Setting up To prepare your computer to run the samples in this article, complete the following steps: - Download the Excel spreadsheet and sample code. - Create the directory C:\Planet Power, and extract the files to it. - Download Eclipse using the link in Related topics. After downloading Eclipse, extract it to the C:\Program Files\Eclipse directory. - From the link in Related topics, download XOM using the Complete zip link on the XOM site. Then, extract the files to the C:\Program Files\Eclipse\lib directory. - Download Apache POI using the link in Related topics. Extract the files to C:\Program Files\Eclipse\lib. (You will need to create the lib directory.) Now you're ready to start working in Eclipse. Start Eclipse To begin working in the Eclipse IDE, complete these steps: - Start Eclipse by navigating to C:\Program Files\Eclipse\eclipse and double-clicking eclipse.exe. If Windows® displays a security warning, click Run. - In the Workspace Launcher window, replace the path labeled Workspace with C:\Eclipse_Projects, and then click OK. - When Eclipse finishes loading, click the Workbench icon on the right side of the window (see Figure 1). Figure 1. Workbench icon - Right-click in the Package Explorer pane, and then click Import. - Expand General, and select Existing Projects into Workspace. Click Next (see Figure 2). Figure 2. Bring an existing project into the workspace - Click Browse (located beside Select root directory), and navigate to C:\Planet Power\Employees. Select the Employees folder, and then click OK. - Click Finish, as in Figure 3. Figure 3. Import a project into Eclipse The Employees folder should now appear in the Package Explorer pane. Making XOM and Apache POI available to Eclipse Technically, the steps in this section have already been performed in the imported Employees Eclipse project. However, in case you start your own project from scratch, you will need to tell the Eclipse project to use the new XOM and Apache POI downloads. Complete these steps: - Right-click the Employees folder in the Package Explorer, and then click Properties. - Click Java Build Path in the left pane. - Click the Libraries tab. - Click Add External JARs, as in Figure 4. Figure 4. Add external JAR files to the build path - Select the Java archive (JAR) file containing the parts of Apache POI you will use in this sample. (If you are using the same version of POI as this article, the path will be C:\Program Files\Eclipse\lib\poi-3.6\poi-3.6-20091214.jar). Click Open. - Click Add External JARs again. - Select the JAR file containing XOM (If you are using the same version of XOM as this article, the path will be C:\Program Files\Eclipse\lib\XOM\xom-1.2.1.jar). Click Open. - Click OK. Using the ExcelReader.java file For this article, use the file ExcelReader.java, which resides in the Employees project folder beneath src\(default package). Figure 5 shows the file. Figure 5. Opening the Employees project To run the file, click the Run arrow button at the top of the screen, as in Figure 6. Figure 6. Running a Java file Running ExcelReader.java reads information from the cells in the Employee_List.xls spreadsheet and displays it using Eclipse's Console tab, as in Figure 7. Figure 7. The Java output in Eclipse's Console Getting started The key to understanding Java technology is being familiar with the idea of working with objects and instantiating (that is, creating) those objects. The standard format for creating objects to work with is: class objectName = new class(); The objectName is a name for the newly created object. It is like a variable that identifies and provides a way to work with that specific object. Also, information, often in the form of other existing objects, might be inside the parentheses ( ()) after class. The information inside the parentheses is used for creating the new object. Working with files Whenever you work with files in a Java environment, you might experience problems with the file. For example, it could be missing. So, trying to read a file could cause errors. Catch any exceptions that could be caused by manipulating files. To work with Excel files, this article uses the FileInputStream class ( java.io.FileInputStream). FileInputStream represents a file that might not be made of regular text. Because Excel files contain binary data, use FileInputStream instead of the FileReader class, which reads files containing only text characters. Start programming The first step in reading an Excel workbook is to prepare to use the Apache POI and other necessary classes. The classes required in ExcelReader.java include some Apache POI classes, some exception (error) classes, and some file handling classes. Listing 1 shows the code at the top of ExcelReader.java that imports these classes to make them available for use. Listing 1. Importing classes (ExcelReader.java) import java.io.FileInputStream; import java.io.IOException;; After importing the relevant classes, you can begin to program inside the body of the main method using the Apache POI. What does HSSF mean in Apache POI? The Apache POI API programmers chose an unusual naming convention for their classes involving Excel workbooks; they used the prefix HSSF. According to its JavaDocs, the prefix actually stands for Horrible Spread Sheet Format. In fact, according to Wikipedia, POI started out meaning Poor Obfuscation Implementation. Who says programmers don't know how to have fun? The HSSF classes are for working with Excel versions before 2007 (that is, .xls files). A different set of classes—XSSF—is for Excel 2007 and later (that is, .xlsx files). Yet another set of classes—the SS classes—works with both versions. For the sake of simplicity, this article uses HSSF classes. Code samples using the other classes are identified in the Readme.txt file in the Eclipse project you downloaded. Workbooks The HSSF class that represents an Excel workbook in the Apache POI is org.apache.poi.hssf.usermodel.HSSFWorkbook. Pass HSSFWorkbook a FileInputStream into its constructor, and you can expect it to represent the file upon which the FileInputStream is based. But wait! In the JavaDocs for the Apache POI, there is no constructor for HSSFWorkbook that states it can take a FileInputStream. Is using a FileInputStream an undocumented feature? No. There is a constructor that accepts an InputStream. Because FileInputStream is a subclass of InputStream, technically it is also an InputStream, so it can be passed into the constructor. In fact, InputStream is abstract, so some sort of subclass is necessary. FileInputStream will do nicely. When instantiating the FileInputStream, pass it a String describing the path to the Excel file to read. For Windows® files, escape any special characters in the file path, especially the directory-separator backslash ( \). Use double backslashes ( \\) to create one escaped backslash in the file path string. The code in Listing 2 instantiates a new FileInputStream and then instantiates a new HSSFworkbook based on that FileInputStream. Listing 2. Reading an Excel file (ExcelReader.java) public static void main(String[] args) { // Create a FileInputStream to hold the file. // Use double back-slashes to create one "escaped" slash. // Use error handling (try/catch) around its creation in case // the file to read does not exist. // Be sure to import java.io.FileNotFoundException and java.io.IOException, or use // the superclass IOException to handle both. try { FileInputStream excelFIS = new FileInputStream("C:\\Planet Power\\Employee_List.xls"); // Create an Excel Workbook Object using the FileInputStream created above // (which contains the file). // Use error handling around its creation in case of Input/Output Exception HSSFWorkbook excelWB = new HSSFWorkbook(excelFIS); } catch (IOException e) { System.out.println("Input/Output Exception!"); } //End Main Method } Now, staying within the try error handling statement, proceed to gather information from the Excel workbook, starting with its sheets. Sheets and rows A workbook can have several layers of pages called sheets. A sheet object is represented by the HSSFSheet class ( org.apache.poi.hssf.usermodel.HSSFSheet). How many sheets does a workbook have? To find out, you can use the method getNumberOfSheets() on the workbook. For this exercise, however, there's only one sheet, so using its number is simpler. The number of the first sheet is zero (computers like to count starting with zero instead of one). The code will look like Listing 3. Listing 3. Get the sheet (ExcelReader.java) // Start by getting the Spreadsheet (Excel books can have several // sheets). Assuming there is just one sheet, it's the zero sheet. HSSFSheet topSheet = excelWB.getSheetAt(0); After obtaining the sheet object, move across the sheet and work with its data. Helpful methods and properties like these have names that indicate what they do: HSSFSheet.getFirstRowNum()and getLastRowNum() HSSFSheet.getHeader()and getFooter() HSSFSheet.getRow() HSSFSheet.getPhysicalNumberOfRows() To work with data on the sheet, start by getting an HSSFRow ( org.apache.poi.hssf.usermodel.HSSFRow) object, which represents a row in the sheet. One way to get a row is to use getRow() on the sheet and ask for the row by number, as in Listing 4. Listing 4. Get the Row (ExcelReader.java) // getRow() returns an HSSFRow object, but the numbering // system is logical, not physical, and zero based. // for example, use getRow(2) to get the third row. HSSFRow thirdRow = topSheet.getRow(2); Remember, topSheet is the sheet obtained earlier in Listing 3. After obtaining the row from the sheet, use the row to drill down to the cell level. Cells To dig down to an individual cell's data, use the row to get an HSSFCell object ( org.apache.poi.hssf.usermodel.HSSFCell) representing that cell. To get cell information that is in String format, use the getStringCellValue() method on the HSSFCell, as in Listing 5. Listing 5. Get the cells and strings inside (ExcelReader.java) // Get the first two cells in the row HSSFCell lastnameCell = thirdRow.getCell(0); HSSFCell firstnameCell = thirdRow.getCell(1); // Get the string information in the cells String firstName = firstnameCell.getStringCellValue(); String lastName = lastnameCell.getStringCellValue(); // Print out the value of the cells System.out.println(firstName + " " + lastName); To gather all of the information from the workbook, iterate through all of the sheets, each row in each sheet, and each cell in each row. But there is a catch: Try running the code below, and it works for some of the cells. However, it will quit with an error attempting to extract the cell value and print it out (see the comment in Listing 6). Why? Listing 6. Loop through all cells and print out values. Broken! // Traverse the sheets by looping through sheets, rows, and cells. // Remember, excelWB is the workbook object obtained earlier. // Outer Loop: Loop through each sheet for (int sheetNumber = 0; sheetNumber < excelWB.getNumberOfSheets(); sheetNumber++) { HSSFSheet oneSheet = excelWB.getSheetAt(sheetNumber); //); // Get the value of the string in the cell. // Print out the String value of the Cell // This section will result in an error. Why? String cellValue = oneCell.getStringCellValue(); System.out.println(cellValue + ", "); // End Inner Loop } // End Middle Loop } // End Outer Loop } What goes wrong? The method getStringCellValue() only works for Strings. Thus the name. Some of the cells contain numeric values. To avoid the error, test the cell's data type and use the appropriate method for getting that data type out of the cell. Use getCellType() to determine what type of data the cell contains. The type of data is returned as an integer that represents the data type. The following static fields (constants) represent the data types: HSSFCELL.CELL_TYPE_STRING. Use getStringCellValue(). HSSFCELL.CELL_TYPE_FORMULA. Use getCellFormula(). HSSFCELL.CELL_TYPE_NUMERIC. Use getNumericCellValue(). HSSFCELL.CELL_TYPE_BOOLEAN. Use getBooleanCellValue(). The cell might also contain an Excel error. If so, getCellType() returns the integer HSSFCELL.CELL_TYPE_ERROR. While iterating through the cells, test their data types, as in Listing 7. Listing 7. Test for the cell value type (ExcelReader.java) // Inner Loop: Loop through each cell in the row for (int cellNumber = 0; cellNumber < cells; cellNumber++) { HSSFCell oneCell = oneRow.getCell(cellNumber); // Test the value of the cell. // Based on the value type, use the proper // method for working with the value. // If the cell is blank, the cell object is null, so don't // try to use it. It will cause errors. // Use continue to skip it and just keep going. if (oneCell == null) { continue; } switch (oneCell.getCellType()) { case HSSFCell.CELL_TYPE_STRING: System.out.println(oneCell.getStringCellValue()); break; case HSSFCell.CELL_TYPE_FORMULA: System.out.println(oneCell.getCellFormula()); break; case HSSFCell.CELL_TYPE_NUMERIC: System.out.println(oneCell.getNumericCellValue()); break; case HSSFCell.CELL_TYPE_ERROR: System.out.println("Error!"); break; } // End Inner Loop } When the code runs, notice that dates are displayed as numbers, not dates. That's because the format of the date is not stored in its value. It's a formatting choice for the cell. Part 2 of this article series will discuss how to preserve the format for dates. One more important note: In the following lines of code from Listing 7, broken out in Listing 8 below, the code tests each cell to make sure it's not null. Listing 8. Don't forget to test for null (ExcelReader.java) // If the cell is blank, the cell object is null, so don't // try to use it. It will cause errors. // Use continue to skip it and just keep going. if (oneCell == null) { continue; } In a Java environment, if an object is null, trying to manipulate it causes an error. Before using objects like rows and cells, be sure to test them to make sure they are not null. Conclusion Armed with the basics of reading Excel spreadsheets, you can begin to convert Excel data into arrays, XML, or other formats to perform calculations or create new spreadsheets. Part 2 of this article series will demonstrate how to convert spreadsheet information to XML and create a new spreadsheet with modifications to the original data. When finished with the code in these articles, be sure to recycle it for greener reporting. Downloadable resources - PDF of this content - Sample Excel spreadsheet and Java code (Java-Excel-XML-Planet-Power.zip | 30KB) Related topics - Read, recycle, and reuse: Reporting made easy with Excel, XML, and Java technologies, Part 2: Convert between XML and Excel reporting formats (Shaene M. Siders, developerworks, March 2010): Convert information in Excel spreadsheets into well-designed XML documents for reuse in a variety of settings in Part 2 of this series by the author. - What's Wrong with XML APIs (and how to fix them): Review Elliotte Rusty Harold's slide presentation to explore some of the differences among types of XML parsers. - XML and Java technologies: Data binding, Part 2: Performance (Dennis Sosnoski, developerWorks, January 2003): Take XML data binding frameworks out for a test drive. - Java Excel API: Explore this Excel API. - OpenXLS: Explore this Excel API. - JavaDoc documentation for Apache POI: Browse the Apache POI documentation. -.
https://www.ibm.com/developerworks/library/x-jxmlexl/
CC-MAIN-2017-47
refinedweb
3,292
57.98
Tuple<T1, T2, T3, T4> Class Represents a 4-tuple, or quadruple. System.Tuple<T1, T2, T3, T4> Namespace: SystemNamespace: System Assembly: mscorlib (in mscorlib.dll) Type Parameters - T1 The type of the tuple's first component. - T2 The type of the tuple's second component. - T3 The type of the tuple's third component. - T4 The type of the tuple's fourth component. The Tuple<T1, T2, T3, T4> type exposes the following members. A tuple is a data structure that has a specific number and sequence of values. The Tuple<T1, T2, T3, T4> class represents a 4-tuple, or quadruple, which is a tuple that has four components. You can instantiate a Tuple<T1, T2, T3, T4> object by calling either the Tuple<T1, T2, T3, T4> constructor or the static Tuple.Create<T1, T2, T3, T4>(T1, T2, T3, T4) method. You can retrieve the value of the tuple's components by using the read-only Item1, Item2, Item3, and Item4 instance properties. Tuples are commonly used in four different ways: To represent a single set of data. For example, a tuple can represent a database record, and its components can represent individual fields of the record. To provide easy access to, and manipulation of, a data set. The following example defines an array of Tuple<T1, T2, T3, T4> objects that contain the names of baseball pitchers, the number of innings they pitched, and the number of earned runs (runs that scored without fielding errors), and hits that they gave up. The array is passed to the ComputeStatistics method, which calculates each pitcher's earned run average (the average number of runs given up in a nine-inning game), and the average number of hits given up per inning. The method also uses these two averages to compute a hypothetical effectiveness average. using System; using System.Collections.Generic; public class Example { public static void Main() { Tuple<string, decimal, int, int>[] pitchers = { Tuple.Create("McHale, Joe", 240.1m, 221, 96), Tuple.Create("Paul, Dave", 233.1m, 231, 84), Tuple.Create("Williams, Mike", 193.2m, 183, 86), Tuple.Create("Blair, Jack", 168.1m, 146, 65), Tuple.Create("Henry, Walt", 140.1m, 96, 30), Tuple.Create("Lee, Adam", 137.2m, 109, 45), Tuple.Create("Rohr, Don", 101.0m, 110, 42) }; Tuple<string, double, double, double>[] results= ComputeStatistics(pitchers); // Display the results. Console.WriteLine("{0,-20} {1,9} {2,11} {3,15}\n", "Pitcher", "ERA", "Hits/Inn.", "Effectiveness"); foreach (var result in results) Console.WriteLine("{0,-20} {1,9:F2} {2,11:F2} {3,15:F2}", result.Item1, result.Item2, result.Item3, result.Item4); } private static Tuple<string, double, double, double>[] ComputeStatistics(Tuple<string, decimal, int, int>[] pitchers) { var list = new List<Tuple<string, double, double, double>>(); Tuple<string, double, double, double> result; foreach (var pitcher in pitchers) { // Decimal portion of innings pitched represents 1/3 of an inning double innings = (double) Math.Truncate(pitcher.Item2); innings = innings + (((double)pitcher.Item2 - innings) * .33); double ERA = pitcher.Item4/innings * 9; double hitsPerInning = pitcher.Item3/innings; double EI = (ERA * 2 + hitsPerInning * 9)/3; result = new Tuple<string, double, double, double> (pitcher.Item1, ERA, hitsPerInning, EI); list.Add(result); } return list.ToArray(); } } // The example displays the following output; // Pitcher ERA Hits/Inn. Effectiveness // // McHale, Joe 3.60 0.92 5.16 // Paul, Dave 3.24 0.99 5.14 // Williams, Mike 4.01 0.95 5.52 // Blair, Jack 3.48 0.87 4.93 // Henry, Walt 1.93 0.69 3.34 // Lee, Adam 2.95 0.80 4.36 // Rohr, Don 3.74 1.09 5.76 To return multiple values from a method without the use of out parameters (in C#) or ByRef parameters (in Visual Basic). For example, the previous example returns its computed statistics, along with the name of the pitcher, in an array of Tuple<T1, T2, T3, T4> objects.> object as the method argument, you can supply the thread’s startup routine with four items.
http://msdn.microsoft.com/en-us/library/dd414846.aspx
CC-MAIN-2013-48
refinedweb
660
61.43
Join devRant Pipeless API From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More Search - "bob" - After reading a lot of cryptography, I realized that it would be best if Alice and Bob just talk in person14 - Boss: "I don't want to comply with the GDPR" Me, DPO: "I've told you the house rules. You must comply, stop arguing" Boss: "But I don't want it. Bobby doesn't have to, and Eve doesn't have to, their moms are cool" Me: "I don't give a crap about the other kids, you're going to be GDPR compliant. Bob and Eve will end up being raped in prison. It's that what you want?" Boss: "What if I just pretend to do it." Me: "I'll take away all your marketing toys. No more mailchimp for you young man." Boss, crying: "You wouldn't touch my Facebook pixel!" Me: "Especially your Facebook pixel. I'm so sick of that thing...." Me: "...Look, you can still play with your toys, all I'm saying is you need to be honest and ask your buddies for consent before you put your pixels up their various holes" Boss: "But they will never agree!" Me: "Maybe that is good thing" Boss: "But how will we get people to like us if I can't feed them pills and insert probes into their holes to measure their responses?" Me: "Maybe you should focus on being a nice kid, someone people like to play with. Your buddies will tell other kids that you're a nice guy. Now, I'm not going to lie to you, it will be hard work. Much more effort than what you're doing now. But you know, those friends will stick with you for decades, instead of just until the marketing-drugs wear off" Boss: "I think I want a new mom" Me: "You signed a contract. You're stuck with me for the next 2 years. And as long as you're living under my roof, you will follow my rules."15 - - *at work* (fictional names) Kevin (linux support engineer): Bob, could you come for a second to take a look at something? Bob (senior linux engineer): *tiny voice from a corner behind a desk* bob is not available right now. Please try again later. Kevin: Bob, please, just for a second! Bob: bob is not available right now, please try again later. Kevin: Boooooooooooooob, come heeeeereeeee Bob: as said before, bob is not available right now, try again later. Kevin: but booooooob, come oooooon. Bob: it seems that you might have a hearing problem since bob is still not available. Kevin: but booooohooooob, come heeeeeeeeeeereee Bob: it seems like the person on the other side of this line might be retarded. Bob is not available right now. Kevin: But boooohooooohooooooob come oooohooohooon, just for a seeehehecond *starts fake sobbing" Bob: Bob is getting real tired of your shit. Leave bob alone. 😆20 - - Meanwhile at NSA: Alice: Uhm... Bob? I lost my SSH key... Bob: *facepalms* Alice: ... but i still have the public key! Could you please recalculate the private one for me? Bob: Sure, give me a second. I'll fax it to you when it's ready. Me: *wakes up from nightmare*13 - - - - "I have a terminal illness" *room goes silent* "so I stopped using the terminal" *bob throws his keyboard at me*5 - - - Normal people talking: Alice: Are you on Facebook? Bob: No. Alice: OMG!!! YOU'RE NOT ON FACEBOOK!? Do you live under a rock? Programmers talking: <Replace all instances of Facebook with github. - - - Code review: - Almond: This method here is a mix of convoluted loops conditionals and ternaries... I really don't think we can pass this. Can we make sure this logic is a lot clearer? - Bob: Oh, ok, sure. I'll work on that. Next day: - Bob: I've hopefully cleared up the meaning of that code now. - Almond: Sure, let me look. Err... it looks the same to me? Have you done it in another branch? - Bob: Oh no, it is the same, but there's a link in the code now to a PNG of a flowchart I put together in draw.io to show how it works. ...🤦♂️18 -'ve put my nose down the books regarding cryptology quite alot lately, and at the end of the day, I really think that Bob and Alice should just meet and talk in person.4 - - The proper use of comments is to compensate for our failure to express ourself in code. Quote of the book "Clean Code" by "Uncle Bob". #ShotsFired6 - - Bob listens to his client... Bob do what the client asks for... Bob is a happy developer... Be like Bob... . . . . Said no one - Hilariously cool error. I mean, not everyday your editor tells you to meditate or sing you a bob Dylan’s song, right? That’s a nice touch atom.2 - Me: i have to pass this test tomorrow so I better study Me to me: start an overambitious project that will take years to complete3 - - - GODADDY IS THE BANE OF MY FUCKING EXISTANCE I WOULD LIKE TO MEET THAT GUY BOB PARSONS SO I CAN STAB THAT FUCKER IN THE GOD DAMMED BALLSACK15 - - - Best non-technical description of why we hate to post in forums (shamelessly copied from Shamus Youngs blog found here:...) -> - - Does anyone know if there's a Bob Ross of development? I feel like I just need to hear someone coding or talking best practices in a chilled out relaxing way to help me through the day - - Oh F***, not again! Bob, every single time you "patch" the servers I run into issues, that you cannot fix. Bob: "heuuu... I don't know anything about python or npm or any of that" Then stop touching it!!!2 - - - Just made a 10-minutes change on the website for a client for free while the company originally in charge of her website development wanted to charge her 660€. For a simple <script> tag.8 - Bob Tabor. He is one of my favourite tutors. Fell in love with C# after starting with his videos.11 - u/bob "hey can someone help me assign 10 to a variable in rust" u/1337rustpro "Well first of all little shithead that is not rust-like we dont do that in rust here is how godfather mozilla intended it first you create a register in your ram then you download these 9 packages that are not in std for some reason then you box your integer 78 times then you sacrifice a goat that the rust compiler doesnt give you random advice that doesnt work then you pee on your motherboard and commit 53 times to open source repos on github bitbucket and svn then you will maybe probably have 7 assigned to your variable" u/bob "Oh wow rust sure is overly complicated" u/bob <User banned>4 - - - Uncle Bob says: Software Craftsmanship is not about glory and rockstar status. It’s not about being the overtime hero, or the last minute cowboy. Rather it is about discipline, professionalism, and the desire to constantly improve.3 - Uncle Bob and Martin Fowler. Their books (“Clean code”, “Clean architecture”, “Refactoring”) and Twitter posts have changed the way I look at software development.5 - - The robots had been instructed to work out how to negotiate between themselves, and improve their bartering as they went along.8 - User logins testing: How others name their imaginary users: Admin John Jane Bob How I name my imaginary users: Root (admin) Alice Floyd4 - - Bob Martin. His books Clean Code and the Clean Coder, and all his talks on architecture, SOLID and TDD. I could listen to him talk for days, and he taught me everything i know about writing clean code.3 - Manager: "Hi Almond, how is X going?" Almond: "...I don't know, Bob is in charge of that." Manager: "Ok. Do you know the status of Y at all?" Almond: "Not sure, isn't that Bob's responsibility too?" Manager: "Well, yeah, but I never seem to be able to get a good answer out of him. Find out on both fronts and let me know ASAP please" ...sure, I know how this goes. I'll stop all the dev work I'm doing, do your job for you, talk to the lazy bonehead that never bothers doing anything, report back that he's done sod all (or still "in a requirements gathering phase" as he puts it), be asked "why is he taking so long", have a bit more back and forth, then decide we'll just leave him be as actually trying to get him to do any work is going to be too much like hassle 😒 - - - Even if interdimensional monsters are looking for you... never forget to naming your variables! #Bob4 -...2 - Realized I hadn’t subjected you guys to cat photos. The brown cat is Robert Lazarus (the rescue named him Bob) and the white and brown cat is Dylan Thomas (rescue named him Dylan). Bobcat died as a kitten (thus his middle name) and was brought back to life, but was blind for a bit as a result. According to legend, Tomcat acted as his seeing eye cat when he wasn’t able to see on his own. Bobcat’s vision’s better now (though he still might have some issues as he’s a little iffy on balance sometimes), but the rescue didn’t want to separate the two of them since they were a bonded pair. Loads of people wanted Tomcat but didn’t want to take a chance on a zombie cat. Which I’m constantly thankful for because they’re awesome. Even if they steal my keyboard and try to eat my notes and try (and succeed) to jump on me while I’m trying to cook because they want to play with the feather toy that’s been hidden (not so well!) on top of the fridge and know it’s their best shot at getting up there.11 - Don't you hate it when your co-worker does dumb things, but thinks it's the "clean code" way? The following is a conversation between me and a co-worker, who thinks he's superior to everyone because he thinks he's the only one who read the Clean Code series. Let's call him Bill. Me: I think the feature we need is quite simple, our application needs to call this third party API, parse the response and pass it to the next step. Why do you need to bury everything under an abstraction of 4 layers? Bill: bEcAuSe It'S dEcOuPlInG, aNd MaKe ThE cOdE tEsTaBlE Me: I don't know man, you only need to abstract the third party api client, and then mock it if you want. Some interfaces you define makes no sense at all. For example, this interface only has 1 concrete implementation, and I don't think it will ever have another. Besides, the concrete implementation only gets the input from the upper layer and passes it down the lower layer. Why the extra step? I feel like you're using interface just for the sake of interface. Bill: PrOgRaMmInG tO iNtErFaCe, NoT cOnCrEtE iPlEmEnTaTiOn!!! Me: You keep saying those words, I don't think they mean what you think they mean. But they certainly do not mean that every method argument must be an interface Bill: BuT uNcLe BoB blah blah blah... Me: *gives up all hope*14 - - When i started ocaml. Now most languages use import lib; But not ocaml. No, it uses open lib; So i had the genius idea of writing my own lib and submitting my program as open Bob; let () = show "vegana";;3 - - - "No matter how slow you are writing clean code, you will always be slower if you make a mess." - Uncle Bob Martin1 - - So, stranger things season 2, Bob is hacking a system with BASIC, writing entire lines with one keyboard press. Such skill. Much wow. Have I missed something lately? xD10 - - If you're good at the debugger it means you spent a lot of time debugging. I don't want you to be good at the debugger. - Uncle Bob2 - - "The only way to make the deadline - the only way to go fast - is to keep the code as clean as possible at all times." Uncle Bob Spread the word.1 - - [...] we should never ignore any part of code. The parts we ignore are where the bugs will hide. - Uncle Bob - - That feeling when you're finally able to reproduce a bug... Now it's time to dig through the logs to see what actually happened.1 -. - Want maximum efficiency in python? def say(text): print(text) You save 2 keypresses everytime you print16 - Meet today.... Fetlang --- lick Bob's cock lick Duke's left nipple one million times while Ada is submissive to Duke make slave scream Ada's name Have Charlie spank himself Have Ada lick his tight little ass Have Bob lick Charlie's tight little ass, as well make Ada moan Bob's name make Bob moan Charlie's name --- Never felt so dirty after calculating the fibonacci sequence...... "Fetlang is a statically typed, procedural, esoteric programming language and reference implementation. It is designed such that source code looks like poorly written fetish erotica."8 - - - know people have mixed feelings about Uncle Bob and I really never followed the guy at all, but back in college I found his book Clean Code on a shelf and read it cover to cover. A lot of it really stuck with me. In fact, I might dig it up again now that I'm thinking about it.3 - Ok I fucked up.. I installed elementary OS on a USB from my school pc.. Windows still work but I have to plug in the elementaryOS USB for grub to boot so I can boot windows Fuck me14 - - - #.18 -." - - My Dev hero is without a doubt Robert C Martin (Uncle Bob). His books clean code and the cleans coder changed the way I program and his work on TDD too6 - <> Rant An interesting perspective considering how much of their code could literally mean life or death. - Robert C. Martin. Clean code philosophy changed everything. Reading code ala Uncle Bob is like a binary search to the place in the code you want to work on" - "Talent is a pursued interest. In other words, anything you are willing to practice, you can do. " - Bob Ross1 - - - Quote by Uncle Bob: “Never forget that, as programmers, you are stakeholders too. Your technical and ethical reputation is on the line. You have a say. You also have feet.” - Every data communication example has Alice and Bob communicating with each other. I wonder after all these years how are they able to maintain a stable relationship. I wish my girlfriend understood this. - I'd say Uncle Bob, since I ended up flying through his Clean Code book in order to get a placement job, but in reality, it's probably only partially that. Most of my influence probably comes from the guy I shadowed under when I was on placement. He taught me way more than he probably ever realises, - - I want an tv series for developers, like "painting with bob ross" was for painters. "Oh i made 3 bugs. Oh dear. Lets make them birds now, yep they are birds now"3 - Q: Why did the C developer wear glasses? A: Cause he had fucking myopia bob! Not everything in about programming! Get your head out of your ass!5 - "Talent is a pursued interest. In other words, anything you are willing to practice, you can do." - Bob Ross4 - ): - - When a fellow programmer/teammate, who tends to be a little to extroverted for my tastes, decides he had nothing to do for the last hour and wants to come talk. An hour and a half later it finally makes sense to just call it a day. - -1 - "Where an expression’s main job is to produce a value, a statement’s job is to produce an effect." That's the cleanest way of explaining the difference between expressions and statements I've ever seen. Kudos to you, Bob. craftinginterpreters.com if anyone's interested! - Not a rant, but may prevent millions of rants later. Also not spam. Just found out someone built a "syntax database" so you can search for the proper syntax. Currently supports nine languages plus api support for additional integration. -. - @dfox Awesome devrant podcasts. Seriously, if you enjoy devrant you will be really impressed with the two they have done so far. Surprised at the five star guests they have gotten so far. Just need to net Uncle Bob. - - - Is it just me or do you guys also bob your head back and forth in sync with the devRant logo when it takes too long to load? -. - - This comes up when I search on Google 'what is code' lol this looks like a bob the builder remake all about code - - - 2 years ago I thought you had to make an if statement for every coordinate in a game to make the character move1 - - - Uncle Bob, Martin Fowler, Kevlin Henney, Doc Norton, Allen Holub. They have all taught me great things about software development, whether through books or superb conference talks. - Just got done watching a 2 1/2 hours of Uncle Bob on programming. I really like his style of speaking. Great data and interesting viewpoints. Really easy to follow. I'd read some of his articles, but never listened to him before. Will definitely be watching more. For those of you in organizations using "agile" development and having a tough time of it, his talk called The Land that Scrum Forgot was really interesting. And he really looks amazingly like my uncle, Tom, who's also been a programmer for decades! So I just think of him as Uncle Tom instead.1 - - - - When your new upgrade process looks like it will save you a few hours of time. After 18 hours and scrapping the improved process we've finally got the green light. -1 - - Rant pending... So our company has been talking about bringing in the full Atlassian suite (JIRA, Bamboo, Bitbucket, Fisheye and Crucible). Anyone familiar with using the entire suite? Just wondering what kind of hell to expect.13 - - - My new boss just asked me why I, a grown man had a minion figure at my desk. I told him it was Bob and it's from where they found their new master or boss - so since I just found my new boss it made sense right? - Now I'm not sure if he thinks I'm a freak or funny.3 - - - "No matter how many times your amazing, absolutely brilliant work is rejected by the client, for whatever dopey, arbitrary reason, there is often another amazing, absolutely brilliant solution possible." - Bob Gill - Through Microsoft Virtual Academy, Watched Bob Tabor's awesome C# tutorial. I used MBA because it had something like a point system which resets every month, made me want to learn more so I end up on top of the list.1 - Most places that I have worked have had a friendly theme of software vs electrical vs mechanical. A lot of the time I have been on both the electrical and software "sides". I am always on the lookout for messing with these groups. Probably why I like devrant. So I thought about a way to mess with electricals. Bob: Man, we are having issues figuring this problem out. Me: I think it needs a temporal adjustment. Bob: What? Me: You need to use a "toroidal condenser".3 - - I'm starting on C# and some of the lesson plans out there dont make sense. So far Bob Tabor and Plural Sight has helped me half way and the bulgarian shark book too. What has helped you cross that threshold past the basics. I'm stuck on structs, namespaces, sort algorithms, sql and json.6 -.1 - ! rant and also sorry if duplicate. Just a shout out the devRant team and devRant community! Just found this article on FossBytes -- - !rant Anyone from Sweden? I found an engineer position I want to apply for, but was curious about things like quality of life and such.12 - - !Rant Does people add in @dfox and @trogus so that they can point out that it isn't a feature yet when/if they see the rant2 - “The proper use of comments is to compensate for our failure to express yourself in code.” – Uncle Bob Martin2 - - - Want do you think about the idea that if the world of development does not develop best practices and standards that governments will see it as a threat and try to regulate standards? It is something Bob Martin talks about. - Bob Dylan: Next one for John Carmack, please. (at least according to... ) - - Be agile, practice patterns, read the core literature (GoF, uncle Bob...) Actually finish a pet project. - I learnt programming basics in C language in highschool because it was taught there and I was pretty good with grasping concepts. However, I had no intention to have career in programming or had clear idea where / how to apply programming knowledge. It was only after i made half way thru college on a stream i lost interest in...that my sense kicked in and I watched Bob Tabors C# lessons on MVA that I really felt like i know programming. Now i can't imagine doing anything other than coding / being a dev. - - Audience question to Uncle Bob: Which parts of the code do you unit test? What about code coverage? Uncle Bob: Well (chuckling).. You test the parts of the code that you want to work. Top Tags
https://devrant.com/search?term=bob
CC-MAIN-2021-10
refinedweb
3,665
81.43
Papervision3D + GoASAP = Go3D Well, ok the name needs some work, but temporarily I’ll call it this since I’m using GoASAP under the hood of Go3D Tween classes. The idea is simple: Write a tween class specifically catering to a DisplayObject3D with x, y, z, rotationX, rotationY, rotationZ properties. What I ended up with was Tween3D (again, the name will likely change as this is a bit generic). Now, after all my rants about untyped objects blah blah blah, I’ve really come to at least appreciate *why* people use this approach. It certainly is faster to type and get something up and running. But, I didn’t want to walk down that path with this one AND I wanted something reusable. I think there are situations where you can waste alot of time recreating these transient tweens within the body of your code that could easily be re-executed after being created one time. Tween3D does this. It’s not a magic trick by any means, I’m simply initializing the “start” values when a Tween3D actually “starts”. It’s very simple and allows for reuse and instantiation. I really wanted to take this on for a couple of reasons, but mainly to get into writing my own tween classes using Go. I’ve had the pleasure of being able to sit and talk to Moses at length about what Go is and the first thing I wanted to do ever since was try my hand at creating a strongly typed API. So far so good, but I think there’s room for improving the amount of code you have to write. It’s actually pretty compact and very easy to understand, but still, I’d like to see some even shorter ways of creating strongly typed tweens. As you might expect, if you’ve used Fuse or Tweener in the past, a strongly typed tween might look like this: [as] var tween:Tween3D = new Tween3D(target:DisplayObject3D, duration:Number, easing:Function, delay:Number); tween.x = 2000; tween.y = 1000; tween.start(); [/as] As you can see, its alot like a Tweener call, except the properties aren’t in an untyped object, they set after instantiation. This setup is good for a few reasons: 1. Faster – always faster to set properties after instantiation than it is through the constructor 2. Strict typing – easy to understand what you can and can’t do with the Tween3D 3. reusable – you can create once, and reuse the tween over and over. This is nice in a situation where tweens are kept in a manager class that someone else maintains through out a project. Single point of management can be a very cool thing. This can also keep the CPU hit down when you need a tween. Another thing about GoASAP is the Sequencing classes that come with it. Alot of times I’ve used Fuse for sequencing events, not necessarily animation tweens 🙂 The sequencing is a very strong and abstract part of GoASAP. If you need it, great, hook it up. If you don’t, then it’s not there apart of the payload. Adding your own custom managers is a snap as well. if you need the OverlapManager that comes with Go, you can hook it in with one line of code. You can also create your own or just leave it out altogether. I’ll be covering Go3D at the classes in Vancouver (this weekend) and Toronto in June, but you can get the source here and the Rolodex demo files here. Its definitely in early stages, but I think it’d be great to get some input if anyone’s interested. You’ll also need to sync or download GoASAP here. Tween3D is written specifically for use with Papervision3D’s DisplayObject3D, so if you’re gonna play, you obviously need to use it with a 3D scene and 3D objects 😉 +++++++ [ shameless classes plug ]++++++++++ Vancouver: May 3rd & 4th This demo below is something I converted from Tweener to using Go3D. The lines of code were more for sure, but thats because of what GoASAP isn’t assuming for me like other animation engines would have to. So, I had to add a Sequence and an OverlapManager to acheive the same effect. Ok so it’s more complexx, but it’s also a ton more flexible. if I didn’t like Moses’ OverlapManager, i could write my own. if I didn’t like his sequencer, I could write my own and plug it in. The point is, I can completely customize any portion of the Tween engine to my project, company or general tastes at any given level. Companies can actually dictate the API and have maximum control over *what* the tween/sequence engine is doing in their application. I think once people realize what GoASAP is, we’ll see alot of uses for it in many ways we’re not even able to comprehend yet. Code for this animation sequence: [as]package { import com.rockonflash.go3d.Tween3D; import com.rockonflash.go3d.utils.Equations; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.MouseEvent; import flash.utils.getDefinitionByName; import org.goasap.GoEngine; import org.goasap.events.GoEvent; import org.goasap.managers.OverlapMonitor; import org.goasap.utils.SequenceCA; import org.goasap.utils.SequenceStepCA; import org.goasap.utils.customadvance.OnDurationComplete; import org.papervision3d.cameras.FreeCamera3D; import org.papervision3d.materials.MovieMaterial; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D; //import com.rockonflash.go3d.utils.Equations; public class RolodexGODemo extends Sprite { public var target :Plane; public var viewport :Viewport3D; public var scene :Scene3D = new Scene3D(); public var camera :FreeCamera3D = new FreeCamera3D(11); public var renderer :BasicRenderEngine = new BasicRenderEngine(); public var sequence :SequenceCA; public var tween_0 :Tween3D; public var tween_0b :Tween3D; public var tween_1 :Tween3D; public var tween_2 :Tween3D; protected var doLoop :Boolean = true; public function RolodexGODemo() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; init(); } public function init():void { GoEngine.addManager(new OverlapMonitor()); viewport = new Viewport3D(0, 0, true, false); addChild(viewport); var cls:Class = getDefinitionByName(“rolodex”) as Class; var rolodex:Sprite = new cls() as Sprite; var mat:MovieMaterial = new MovieMaterial(rolodex, true, false); mat.smooth = true; target = new Plane(mat, 292, 168, 4, 4); scene.addChild(target); reset(); createTween(); finalizeInit(); } protected function finalizeInit():void { stage.addEventListener(MouseEvent.CLICK, handleClick); stage.addEventListener(Event.ENTER_FRAME, loop); loop(); doLoop = false; } protected function loop(e:Event=null):void { if( !doLoop ) return; // only render when we have to renderer.renderScene(scene, camera, viewport); } protected function handleClick(e:MouseEvent):void { doTween(); } protected function createTween():void { sequence = new SequenceCA(); sequence.addEventListener(GoEvent.COMPLETE, handleSequenceComplete, false, 0, true); tween_0 = new Tween3D(target, 1, Equations.easeOutCubic); tween_0.x = 0; tween_0.y = 50; tween_0.rotationZ = 0; sequence.addStep(tween_0); sequence.lastStep.advance = new OnDurationComplete(.2); // advance early/overlap tween_0b = new Tween3D(target, 1, Equations.easeOutCubic); tween_0b.z = 200; sequence.addStep(tween_0b, true); // 2nd param groups it with previous step. param is “addToLastStep” tween_1 = new Tween3D(target, 1, Equations.easeOutCubic); tween_1.x = -10; tween_1.y = 85; tween_1.rotationZ = 15; sequence.addStep(tween_1); sequence.lastStep.advance = new OnDurationComplete(.25); // advance early/overlap tween_2 = new Tween3D(target, 1, Equations.easeOutBounce); tween_2.rotationX = 0; tween_2.rotationY = 0; sequence.addStep(tween_2); } protected function handleSequenceComplete(e:GoEvent):void { doLoop = false; } protected function reset():void { target.x = (Math.random() * (stage.stageWidth*.5)); target.y = -350; target.z = -1000; target.rotationY = 30; target.rotationX = 30; target.rotationZ = Math.random() *-180;//-10; loop(); } protected function doTween():void { reset(); //createTween(); doLoop = true; sequence.start(); } } } [/as] I gotta say a huge thanks to Moses for putting up with my questions and debugging 😉 It was FUN non the less! Very, very interesting. This is the first time I’ve heard GoASAP. It seems robust. I’ve got to take a look at this soon. By the way, nice animation! Generally we find the most simple way to do tween and have complete control is to tween a value from 0 to 1 or to reverse it 1 to 0. It’s then extremely easy to stop and revers a tween at any point. You then just listen to the change event and update an many properties of as many objects that you want. Just to add to that, if we had a sequence such as your example (4 tweens one after the other), we would just tween from 0-4 and 4-0 to reverse. In the MOTION_CHANGE we would just check the value and change the correct properties. We’d code all the change properties as constants at the top of the class to tweak at any point. “1. Faster – always faster to set properties after instantiation than it is through the constructor” i’m curious about this as it is the first time I have ever heard this. Do you have any specfic references or differences? thanks That’s a pretty interesting approach, if just for readability. While I really like working with TweenLite (and Tweener), sending a generic object definitely has its downsides. I always have to open up the class to see what I can send; Flex hints don’t help with generic objects. Have you seen a significant speed increase from setting properties after instantiation? I would imagine that the major bottlenecks would be elsewhere when using PV3D and any tweening engine. Well, a tween with some properties based on go. Could be the WidthTween of Go with some more properties. In my eyes nothing special, there are much better Go projects out there and the most of them have a bigger functionality. sorry @nicklas: no worries man, it’s not meant to be some break through at all, really just wanted to get people to take a look at go and possibly see in it what I saw. This isn’t meant to be another tween api, it was just mean to say “see, this was pretty easy, and it’s as light weight or as insane as you need it to be. @Tink: so how do you handle a situation where you have a large team of developers or teams separated by continents that might be working with the same objects and properties via the tween engine? Do you guys have an OverlapManager you use to catch these issues? Or, how do you handle the demo above where I tell the second step in the sequence to take over the easeOutCubic .2 before the end of step1? See, in that scenario, I didn’t want the first step to finish, I wanted the next step to take over at a certain point so that we didn’t see it slow down, then bam, ease again for the last little bit of movement for the rotations and bouncing. Do you have something for that as well? AT that point, you’ve literally written your own tween engine I suppose, yes? @Zach: That’s always been my point – strong typing allows tools like Flexbuilder and FDT to provide auto-completion as you type. You’ll always know what’s possible with the tween your creating along with knowing all of the possible event dispatches. The learning curve is 100x’s less. I personally love how fast you can create a tween with 1 line of code with Tweener and fuse, but in reality, you’re just moving the property changes out of the constructor/method call – and it certainly is readable. I think Tweener’s code is readable too, but in all honesty, I can keep track of what’s going on by setting the properties like this much more clearly. Dude. I get a compile error in Flex as an AS project … Error #1065: Variable rolodex is not defined. Any ideas? Tink – Yeah man! That’s *exactly* how Go works, the whole idea is to add absolutely nothing to your code that you don’t use, it is small and simple. The tween base class LinearGo always runs its position property from 0-1 (and can cycle back to 0 as many times as you want, or repeat forwards as many times as you want). And it runs really fast – Check out the benchmarks. 🙂 You can do what you’re doing now, subscribe to an update event on a LinearGo instance to build tweens in your code. But when you come up with some functionality you feel like keeping and reusing, you can very quickly and easily package that up as a LinearGo subclass in just a few steps. That class stays cool, in that it doesn’t pre-define any targets or properties for you, so you can design it to work however you want it to – like John’s version with 3D properties here. Then, there’s Sequence and Group utils thrown in for good measure. Actually another little point too: Go is not “against” Fuse or Tweener “object syntax” at all – it’s very easy to create tween classes or parsers that use that syntax, in fact, with Go! Make up an XML syntax or whatever you want – it’s just a modular OO base system that you can do whatever with. 🙂 PS Thanks John! @lee: I put the FLA in there with the sample and it has a library asset with linkage ID of rolodex – that’s what it’s looking for. You can just change it out to use a generic ColorMaterial or something And just to add to what Moses said: this is not a knock on Tweener by any means – I love Tweener. I would love to see them take their API and put it on top of GO to be honest. That would be great to see that type of adoption of GO and it’s the best of both worlds – an API that people love using a very strong / lightweight GO engine under the hood. Your FLA has no file extension so got lost on the PC. Thanks for this though. Really useful. @lee: sorry about that man, Mac didn’t give it an extension ;( I’ll add that Lovely, the lack of strong typing is a bugger when developing with FDT. Thank you.
https://rockonflash.wordpress.com/2008/05/02/papervision3d-goasap-go3d/
CC-MAIN-2017-22
refinedweb
2,367
65.52
Introduction to the Hadoop Ecosystem Apache Hadoop is an open-source system to store and process much information across many commodity computers reliably. Hadoop has been first written in a paper and published in October 2013 as ‘Google File System’. Doug Cutting, who was working in Yahoo at that time, introduced Hadoop Ecosystem’s name based on his son’s toy elephant name. If we consider the main core of Apache Hadoop, then firstly it can consider the storage part, which known as Hadoop Distributed File System (HDFS), and secondly processing part, which known as Map-Reduce Programming module. Hadoop actually splits one huge file and store them in multiple nodes across the cluster. The concept of Hadoop Ecosystem Apache Hadoop framework is mainly holding below modules: - Hadoop Common: contains all the libraries and utilities needed for using Hadoop module. - Hadoop Distributed File System (HDFS): It is one of the distributed file systems which helps to store huge data in multiple or commodity machines. Also, provide big utility in case of bandwidth, it normally provided very high bandwidth is a type of aggregate on a cluster. - Hadoop Yarn: It introduced in 2012. It is mainly introduced to managing resources on all the system in commodity even in a cluster. Based on resources capability, it distributed or scheduling user’s application as per requirement. - Hadoop MapReduce: It mainly helps to process large-scale data through map-reduce programming methodology. Apache Hadoop always helps on IT cost reduction in terms of processing and storing huge data smartly. As Apache Hadoop is an open-source and hardware is very commonly available, it always helps us handle a proper reduction in IT cost. Open Source Software + Commodity Hardware = IT Costs reduction For example, if we consider daily receiving 942787 files and directories, which require 4077936 blocks, total 5020723 blocks. So if we configured at least 1.46 PB capacity, then for handling above load, the distributed file system will use 1.09 PB, that’s mean almost 74.85% of total configured capacity, whereas we considering 178 live nodes and 24 dead nodes. Hadoop ecosystem mainly designed for storing and processing big data, which normally have some key characters like below: - Volume The volume stands for the size of Data that actually stored and generated. Depends on the size of data it has been determined the data set is big data or not. - Variety Variety stands for nature, structure, and type of data which is being used. - Velocity Velocity stands for the speed of data that has been stored and generated in a particular development process flow. - Veracity Veracity signifies the quality of data that has been captured and also helps data analysis to reach the intended target. HDFS is mainly designed to store a huge amount of information (terabytes or petabytes) across a large number of machines in a cluster. It always maintaining some common characteristics, like data reliability, runs on commodity hardware, using blocks to store a file or part of that file, utilize ‘write once read many’ model. HDFS below architecture with the concept of Name Node and Data Node. The responsibility of the Name Node (Master): – manages the file system namespace – maintains cluster configuration – Responsible for replication management The responsibility of Data Node (Slaves): – Store data in the local file system – Periodically report back to the name node using heartbeat HDFS Write Operation: Hadoop follows below steps for write any big file: - Create File and update the FS image after getting one file write request from any HDFS client. - Get block location or data node details information from the name node. - Write the packet in an individual data nodes parallel way. - Acknowledge completion or accepting packet writing and send back information to Hadoop client. HDFS Block Replication Pipeline: - The client retrieves a list of Datanodes from the Namenode that will host a replica of that block. - The client then flushes the data block to the first Datanode. - The first Datanode receives a block, writes it and transfers it to the next data node in the pipeline. - When all replicas are written, the Client moves on to the next block in the file. HDFS Fault Tolerance: One data node has been down suddenly; in that case, HDFS can automatically manage that scenario. First, all name node is always received one heartbeat from every data node. If somehow it lost one heartbeat from one data node, considering the same data node as down, immediately auto replicate all the blocks on remaining nodes to satisfy replication factor. If the name node detects one new data node available in the cluster, it immediately rebalancing all the blocks, including the added data node. Now somehow Name node loss or failed, in that case, a backup node holding one FS image of name node replay all the FS operation immediately and up the name node as per requirement. But in that case, manual intervention required, and the entire Hadoop ecosystem framework will be down for a couple of times to set up a new name node again. So in this case, name node can be a single point failure, to avoid this scenario HDFS Federation introducing multiple clusters set up of name node, and ZooKeeper can manage immediate up one alternative name node as per requirement. Examples of Hadoop Ecosystem Full Hadoop ecosystem example can be properly explained in the below figure: Data can come from any source like Data Warehouse, Managed Document Repository, File Shares, Normal RDMS databased, or cloud or external sources. All those data came to HDFS in structure or non-structured or semi-structured way. HDFS store all those data as a distributed way, means storing in distributed commodity system very smartly. Conclusion Hadoop ecosystem is mainly designed to store and process huge data that should have presented any of the two factors between volume, velocity, and variety. It is storing data in a distributed processing system that runs on commodity hardware. Considering the full Hadoop ecosystem process, HDFS distributes the data blocks, and Map Reduce provides the programming framework to read data from a file stored in HDFS. Recommended Articles This has been a guide to Hadoop Ecosystem. Here we have discussed the basic concept about Hadoop Ecosystem, its architecture, HDFS operations, examples, HDFS fault tolerance etc. You may also look at the following articles to learn more –
https://www.educba.com/hadoop-ecosystem/
CC-MAIN-2021-21
refinedweb
1,057
50.67
Comparing Rails and Phoenix: Part II Stay connected In the first post of this two-part series, we touched on generating a new application and talked about the entry point to each application: the Router. We also discussed at a high level about how Phoenix apps can fit into larger OTP applications. In this post, we will be looking at the Model, View, and Controller, the parts that comprise a typical MVC framework. The Model The Model, that place where your application's business logic tends to reside and where the schema is defined to be able to talk to the database. Where rows and columns are converted to objects or structs. Here, we'll explore some of the differences in the model layer between Rails and Phoenix. The model in Rails There is a lot of "magic" going on in Rails, and I love it! I purposefully put that word magic in quotes because it isn't really magic. It's logic that is defined in the ActiveRecord::Base class that we get access to as soon as we create a class which inherits from it. Let's take a look at our User class: class User < ApplicationRecord has_many :tweets has_many :notifications validates :email, :name, :username, :bio, presence: true def to_param username end end And with that little code, we suddenly have the ability to query the users table in our database, to validate each object, and to reach out to related objects that we've defined through the two has_many lines. In Rails, we use the model class to find and create instances of that same class. User.find_by(username: "leigh") goes to the database and returns us an instance of the User class that matches the query we gave. We also don't have to tell Rails which columns this table has. It figures all of that out on its own. ActiveRecord is an ORM (Object Relational Mapper); mapping relational data in the database to objects in Ruby. You may wonder why I'm going into detail about things that to a seasoned Rails developer are second nature -- that is because in Phoenix it's done differently. Database migrations in Rails Here are the migrations which were generated with the scaffold command from earlier in the article. class CreateUsers < ActiveRecord::Migration[5.0] def change create_table :users do |t| t.string :email t.string :name t.string :username t.string :bio t.timestamps end add_index :users, :email, unique: true add_index :users, :username, unique: true end end The model in Phoenix The model layer in Phoenix is actually handled by a great library called Ecto. As we take a look at the User model in Phoenix, you'll immediately notice some differences. The first is that we define the different columns and relationships it has in a schema block. Ecto requires you to be a little bit more explicit about your database schema and how it maps to your Ecto model. defmodule TwitterPhoenix.User do use TwitterPhoenix.Web, :model schema "users" do field :name, :string field :username, :string field :email, :string field :bio, :string has_many :tweets, TwitterPhoenix.Tweet has_many :notifications, TwitterPhoenix.Notification timestamps end @required_fields ~w(name username email bio) @optional_fields ~w() @doc """ Creates a changeset based on the `model` and `params`. If no params are provided, an invalid changeset is returned with no validation performed. """ def changeset(model, params \\ :empty) do model |> cast(params, @required_fields, @optional_fields) |> unique_constraint(:username) |> unique_constraint(:email) end end Thankfully, most of that is written for us when we generated the scaffolding for our application, so don't be afraid or turned off by its verboseness. In fact, it is nice to be able to look at your model and immediately see how it is structured. Because Elixir is a functional, immutable language, there are no "objects" as you find in Ruby. Validations and casting of the data are defined inside the changeset method. You provide the existing data in addition to the data you are changing, and it will produce an Ecto.Changeset struct which contains all of the information needed to validate and save the record. Unlike Rails where you use the class and object instances to interact with the database, all of that in Ecto is done through a Repo module. If we look at the update action of the UserController, we'll see two different interactions with Repo along with some interactions with the changeset. def update(conn, %{"id" => username, "user" => user_params}) do # Find a user by its username user = Repo.get_by!(User, username: username) # Generate a changeset using existing user and incoming user_params changeset = User.changeset(user, user_params) # Attempt to save changeset to the database case Repo.update(changeset) do {:ok, user} -> conn |> put_flash(:info, "User updated successfully.") |> redirect(to: user_path(conn, :show, user.username)) {:error, changeset} -> render(conn, "edit.html", user: user, changeset: changeset) end end First we use the Repo.get_by! method to find a User by its username. We then produce a changeset by providing the existing user and the form data (found in user_params). With the changeset we can now use the Repo.update method to attempt to save these changes to the database. Handling the result is done in Elixir style pattern matching rather than the Rails style if statements, but the goal is the same. Database migrations in Phoenix Here is what migrations look like in Phoenix. They look quite similar to the ones in Rails and should be instantly understandable to someone coming to Phoenix from Rails. defmodule TwitterPhoenix.Repo.Migrations.CreateUser do use Ecto.Migration def change do create table(:users) do add :name, :string add :username, :string add :email, :string add :bio, :string timestamps end create unique_index(:users, [:username]) create unique_index(:users, [:email]) end end The Controller Controllers sit sort of in the middle of a web request. We get to the controller by way of the routing, and it's the controller's job to basically convert incoming request (and its params) into a response. It does so by interacting with the Model layer and then passing that data to a view who presents the data as HTML or JSON. We're going to be looking at the TweetsController, more specifically at the index action, which shows the latest tweets for a specific user, in this case. Controllers in Rails With controllers in Rails, we typically end up in a method referred to as the action. This is the method that the router calls and whose job it is to gather data from the model and pass it to the view. Let's take a look at the index action: class TweetsController < ApplicationController before_action :set_user def index @tweets = @user.tweets.latest end private def set_user @user = User.find_by(username: params[:user_id]) end end The index method is quite small, but what's actually going on here? In Rails, you can have before_action filters which happen before the action actually gets called. These can set data (such as the @user variable) and perform security authorization checks, among other things. We declared that we wanted a before_action to take place at the top of the controller and defined the actual method itself further below. Inside the set_user method, we're using data that has come to us via the URL. The path which maps to this action looks like /users/:user_id/tweets, so if we want to grab this user's latest tweets, we first need to find the user, using their ID (username in this case). In Rails, we have access to URL params, GET params, and POST data all through a single object, the params. This may look like just a hash, but it's a little more complicated than that. We can actually use it to validate our incoming parameters using StrongParameters, which can require certain fields to exist and permit (whitelist) others. In this case, we are just grabbing the user_id. Just one note about this is that the user_id here is actually their username. It could have been redefined to username in the routing, but I just went with the default naming convention. Variables are passed to the view by setting them as instance variables ( @ variables) rather than local ones. In this case, rendering happens implicitly by Rails, which knows to look for the index.html template inside the views/tweets folder. We can choose to call the render method if we want more control over the process or something different from the default behavior. Controllers in Phoenix If I were to describe the main differences between controllers in Rails and those in Phoenix, I would say that they are a little simpler and a bit more explicit in Phoenix. The first thing to note in Phoenix is that there is only a single concept which weaves its way through controllers, and that is the same we saw in routing: namely, the plug. There are no filters, no actions, just plugs. It may appear very similar because of some nice macros that help define what is commonly done in filters and actions, but these are just plugs. Also, because Elixir is a functional language, there are no objects we have access to, like the request or params objects which we have in Rails. There is a single conn struct which is passed from plug to plug, containing all of the information of the entire request, including the params. We add or modify this struct as it flows from one plug to another. Take a look at our controller below (I have again removed code which doesn't relate to the specific use-case): defmodule TwitterPhoenix.TweetController do use TwitterPhoenix.Web, :controller alias TwitterPhoenix.{UserTweets, User, Tweet} plug :load_user def index(conn, _params) do tweets = UserTweets.latest(conn.assigns[:user]) render(conn, "index.html", tweets: tweets) end defp load_user(conn, _) do user = Repo.get_by!(User, username: conn.params["user_id"]) assign(conn, :user, user) end end It looks similar to what we saw in Rails. We define what would be a before_action filter (a plug) called load_user. This happens before the index method is called, and we can access the user_id (username) from the conn variable to find the user. We then add its information to the conn struct and send it on its way to the next plug, which happens to be the index method. In the index method, we have to be explicit about rendering the view that we want, passing the variables we want it to have access to. The View We've made it to the point of the request/response life-cycle where we need to render some HTML that will be returned to the user. Views in Rails Views in Rails are pretty self-explanatory. They have access to instance variables which were set in the controller that rendered it, along with a number of other helper methods which come from Rails or which were defined by the user. The default views in Rails are written in ERB (Embedded Ruby), allowing us to mix HTML with Ruby logic. html <tbody> <% @tweets.each do |tweet| %> <tr> <td><%= tweet.body %></td> <td><%= tweet.retweet_count %></td> <td><%= tweet.like_count %></td> <td><%= link_to 'Show', user_tweet_path(@user, tweet) %></td> </tr> <% end %> </tbody> Views in Phoenix Things change quite a bit when we enter Phoenix. Here we don't go from the controller directly to where we write HTML. Phoenix has split things up into "views" and "templates." Views are modules who have the job of rendering the template and providing methods to assist with rendering the data. You can almost think of them as "presenters" for the templates, where you might want to present the data differently if you are rendering HTML vs JSON. It provides a bit of separation between the controller who finds the data, ensures the user is authenticated and authorized, and the template which renders the output. In our case, we aren't doing anything special with the data at the moment, so it is a module with a single method that helps us display the user's name: defmodule TwitterPhoenix.TweetView do use TwitterPhoenix.Web, :view def username(conn) do conn.assigns[:user].username end end The template which produces the HTML actually ends up looking remarkably similar to how things looked in Rails: html <tbody> <%= for tweet <- @tweets do %> <tr> <td><%= tweet.body %></td> <td><%= tweet.retweet_count %></td> <td><%= tweet.like_count %></td> <td class="text-right"> <%= link "Show", to: user_tweet_path(@conn, :show, username(@conn), tweet), class: "btn btn-default btn-xs" %> </td> </tr> <% end %> </tbody> Websockets/Channels With the imminent release of Rails 5, both Rails and Phoenix have support for websockets and channels by default. This wasn't the case prior to Rails 5, and you might say that the implementation in Phoenix is still a stronger one. You may have seen the article that talks about how the Phoenix team achieved two million connections on a single (albeit very large) server. I have yet to see a similar comparison in Rails, although my gut instinct tells me it wouldn't be able to achieve as many (although I'd love to be proven wrong). That being said, there are very few applications which require this sort of scaling. If you are one of them, congratulations, that's awesome! For the majority of websites, Rails should perform just fine, and it's a great addition to the framework. ActionCable (channels) in Rails requires either Redis or PostreSQL to handle the pub/sub nature of channels. You are welcome to use those with channels in Phoenix as well, but they aren't required due to the concurrent-by-default nature of the language. Conclusion In this article, I tried to touch on the main components of an MVC web framework. As many readers will have realized, there is more that I have left out than I was able to include! We didn't get to talk about ecosystems, testing, async processing through queues (or natively in Elixir), email, caching, among other things. But hopefully what I was able to do was to point out a few of the commonalities between these powerful frameworks, as well as other areas where they might differ in terms of their philosophy and/or implementation. If you are interested in taking a look at the code I used in these examples, here are links to the Phoenix app and the Rails app. If you haven't tried Phoenix or the Elixir language before, please do! You won't be disappointed. 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/comparing-rails-and-phoenix-part-ii/
CC-MAIN-2021-17
refinedweb
2,436
62.58
March 2011 Volume 26 Number 03 Data Points - Server-Side Paging with the Entity Framework and ASP.NET MVC 3 By Julie Lerman | March 2011 In my February Data Points column, I showed off the jQuery DataTables plug-in and its ability to seamlessly handle huge amounts of data on the client side. This works well with Web applications where you want to slice and dice large amounts of data. This month, I’ll focus on using queries that return smaller payloads to enable a different type of interaction with the data. This is especially important when you’re targeting mobile applications. I’ll take advantage of features introduced in ASP.NET MVC 3 and demonstrate how to use these together with efficient server-side paging against the Entity Framework. There are two challenges with this task. The first is to provide an Entity Framework query with the correct paging parameters. The second is to mimic a feature of client-side paging by providing visual clues to indicate that there’s more data to retrieve, as well as links to trigger the retrieval. ASP.NET MVC 3 has a slew of new features, such as the new Razor view engine, validation improvements and a ton more JavaScript features. The launch page for MVC is at asp.net/mvc, where you can download ASP.NET MVC 3 and find links to blog posts and training videos to help you get up to speed. One of the new features that I’ll use is the ViewBag. If you’ve used ASP.NET MVC previously, ViewBag is an enhancement to the ViewData class and lets you use dynamically created properties. Another new element that ASP.NET MVC 3 brings to the table is the specialized System.Web.Helpers.WebGrid. Although one of the grid’s features is paging, I’ll use the new grid but not its paging in this example, because that paging is client-side—in other words, it pages through a set of data provided to it, similar to the DataTables plug-in. I’m going to be using server-side paging instead. For this little app, you’ll need an Entity Data Model to work with. I’m using one created from the Microsoft AdventureWorksLT sample database, but I only need the Customer and SalesOrderHeaders brought into the model. I’ve moved the Customer rowguid, PasswordHash and PasswordSalt properties into a separate entity so that I don’t have to worry about them when editing. Other than this small change, I haven’t modified the model from its default. I created a project using the default ASP.NET MVC 3 project template. This prepopulates a number of controllers and views, and I’ll let the default HomeController present the Customers. I’ll use a simple DataAccess class to provide interaction with the model, context and, subsequently, the database. In this class, my GetPagedCustomers method provides server-side paging. If the goal of the ASP.NET MVC application was to allow the user to interact with all of the customers, that would be a lot of customers returned in a single query and managed in the browser. Instead, we’ll let the app present 10 rows at a time and the GetPagedCustomers will provide that filter. The query that I’ll eventually need to execute looks like this: context.Customers.Where(c => c.SalesOrderHeaders.Any()).Skip(skip).Take(take).ToList() The view will know which page to request and give that information to the controller. The controller will be in charge of knowing how many rows to supply per page. The controller will calculate the “skip” value using the page number and the rows per page. When the controller calls the GetPagedCustomers method, it will pass in the calculated skip value as well as the rows per page, which is the “take” value. So if we’re on page four and presenting 10 rows per page, skip will be 40 and take will be 10. The paging query first creates a filter that requests only those customers who have any SalesOrders. Then, using LINQ Skip and Take methods, the resulting data will be a subset of those customers. The full query, including the paging, is executed in the database. The database returns only the number of rows specified by the Take method. The query is composed of a few parts to enable some tricks I’ll add down the road. Here’s a first pass at the GetPagedCustomers method that will be called from the HomeController: public static List<Customer> GetPagedCustomers(int skip, int take) { using (var context = new AdventureWorksLTEntities()) { var query = context.Customers.Include("SalesOrderHeaders") .Where(c => c.SalesOrderHeaders.Any()) .OrderBy(c => c.CompanyName + c.LastName + c.FirstName); return query.Skip(skip).Take(take).ToList(); } } The controller Index method that calls this method will determine the number of rows to return using a variable I’ll call pageSize, which becomes the value for Take. The Index method will also specify where to begin based on a page number that will be passed in as a parameter, as shown here: public ActionResult Index(int? page) { const int pageSize = 10; var customers=DataAccess.GetPagedCustomers((page ?? 0)*pageSize, pageSize); return View(customers); } This gets us a good part of the way. The server-side paging is completely in place. With a WebGrid in the Index view markup, we can display the customers returned from the GetPagedCustomers method. In the markup, you need to declare and instantiate the grid, passing in Model, which represents the List<Customer> that was provided when the controller created the view. Then, using the WebGrid GetHtml method, you can format the grid, specifying which columns to display. I’ll only show three of the Customer properties: CompanyName, FirstName and LastName. You’ll be happy to find full IntelliSense support as you type this markup whether you use syntax associated with ASPX views or with the new MVC 3 Razor view engine syntax (as with the following example). In the first column, I’ll provide an Edit ActionLink so that the user can edit any of the Customers that are displayed: @{ var grid = new WebGrid(Model); } <div id="customergrid"> @grid.GetHtml(columns: grid.Columns( grid.Column(format: (item) => Html.ActionLink ("Edit", "Edit", new { customerId = item.CustomerID })), grid.Column("CompanyName", "Company"), grid.Column("FirstName", "First Name"), grid.Column("LastName", "Last Name") )) </div> The result is shown in Figure 1. .jpg) Figure 1 Providing Edit ActionLinks in the WebGrid So far, so good. But this doesn’t provide a way for the user to navigate to another page of data. There are a number of ways to achieve this. One way is to specify the page number in the URI—for example,. Surely you don’t want to ask your end users to do this. A more discoverable mechanism is to have paging controls, such as page number links “1 2 3 4 5 …” or links that indicate forward and backward, for example, “<< >>.” The current roadblock to enabling the paging links is that the Index view page has no knowledge that there are more Customers to be acquired. It knows only that the universe of customers is the 10 that it’s displaying. By adding some additional logic into the data-access layer and passing it down to the view by way of the controller, you can solve this problem. Let’s begin with the data-access logic. In order to know if there are more records beyond the current set of customers, you’ll need to have a count of all of the possible customers that the query would return without paging in groups of 10. This is where composing the query in the GetPagedCustomers will pay off. Notice that the first query is returned into _customerQuery, a variable that’s declared at the class level, as shown here: _customerQuery = context.Customers.Where(c => c.SalesOrderHeaders.Any()); You can append the Count method to the end of that query to get the count of all of the Customers that match the query before paging is applied. The Count method will force a relatively simple query to be executed immediately. Here’s the query executed in SQL Server, from which the response returns a single value: SELECT [GroupBy1].[A1] AS [C1] FROM ( SELECT COUNT(1) AS [A1] FROM [SalesLT].[Customer] AS [Extent1] WHERE EXISTS (SELECT 1 AS [C1] FROM [SalesLT].[SalesOrderHeader] AS [Extent2] WHERE [Extent1].[CustomerID] = [Extent2].[CustomerID] ) ) AS [GroupBy1] Once you have the count, you can determine if the current page of customers is the first page, the last page or something in between. Then you can use that logic to decide which links to display. For example, if you’re beyond the first page of customers, then it’s logical to display a link to access earlier pages of customer data with a link for the previous page, for example, “<<.” We can calculate values to represent this logic in the data-access class and then expose it in a wrapper class along with the customers. Here’s the new class I’ll be using: public class PagedList<T> { public bool HasNext { get; set; } public bool HasPrevious { get; set; } public List<T> Entities { get; set; } } GetPagedCustomers method will now return a PagedList class rather than a List. Figure 2 shows the new version of GetPagedCustomers. Figure 2 The New Version of GetPagedCustomers public static PagedList<Customer> GetPagedCustomers(int skip, int take) { using (var context = new AdventureWorksLTEntities()) { var query = context.Customers.Include("SalesOrderHeaders") .Where(c => c.SalesOrderHeaders.Any()) .OrderBy(c => c.CompanyName + c.LastName + c.FirstName); var customerCount = query.Count(); var customers = query.Skip(skip).Take(take).ToList(); return new PagedList<Customer> { Entities = customers, HasNext = (skip + 10 < customerCount), HasPrevious = (skip > 0) }; } } With the new variables populated, let’s take a look at how the Index method in the HomeController can push them back to the View. Here’s where you can use the new ViewBag. We’ll still return the results of the customers query in a View, but you can additionally stuff the values to help determine what the markup will look like for the next and previous links in the ViewBag. They will then be available to the View at run time: public ActionResult Index(int? page) { const int pageSize = 10; var customers=DataAccess.GetPagedCustomers((page ?? 0)*pageSize, pageSize); ViewBag.HasPrevious = DataAccess.HasPreviousCustomers; ViewBag.HasMore = DataAccess.HasMoreCustomers; ViewBag.CurrentPage = (page ?? 0); return View(customers); } It’s important to understand that the ViewBag is dynamic, not strongly typed. ViewBag doesn’t really come with HasPrevious and HasMore. I’ve just made them up as I’m typing the code. So don’t be alarmed that IntelliSense doesn’t suggest this to you. You can create any dynamic properties you’d like. If you’ve been using the ViewPage.ViewData dictionary and are curious how this is different, ViewBag does do the same job. But in addition to making your code a little prettier, the properties are typed. For example, HasNext is a dynamic{bool} and CurrentPage is a dynamic{int}. You won’t have to cast the values when you retrieve them later. In the markup, I still have the customer list in the Model variable, but there’s a ViewBag variable available as well. You’re on your own as you type in the dynamic properties into the markup. A tooltip reminds you that the properties are dynamic, as shown in Figure 3. .jpg) Figure 3 ViewBag Properties Aren’t Available Through IntelliSense Because They’re Dynamic Here’s the markup that uses the ViewBag variables to determine whether or not to display the navigation links: @{ if (ViewBag.HasPrevious) { @Html.ActionLink("<<", "Index", new { page = (ViewBag.CurrentPage - 1) }) } } @{ if (ViewBag.HasMore) { @Html.ActionLink(">>", "Index", new { page = (ViewBag.CurrentPage + 1) }) } } This logic is a twist on markup used in the NerdDinner Application Tutorial, which you can find at nerddinnerbook.s3.amazonaws.com/Intro.htm. Now when I run the app, I have the ability to navigate from one page of customers to the next. When I’m on the very first page, I have a link to navigate to the next page but nothing to go to a previous page because there is none (see Figure 4). .jpg) Figure 4 The First Page of Customer Has Only a Link to Navigate to the Next Page When I click the link and navigate to the next page, you can see that there are now links to go to the previous or next page (see Figure 5). .jpg) Figure 5 A Single Page of Customers with Navigation Links to Go to Previous or Next Page of Customers The next step, of course, will be to work with a designer to make this paging more attractive. Critical Piece of Your Toolbox Summing up, while there are a number of tools to streamline client-side paging, such as the jQuery DataTables extension and the new ASP.NET MVC 3 WebGrid, your application needs may not always benefit from bringing back large amounts of data. Being able to perform efficient server-side paging is a critical piece of your toolbox. The Entity Framework and ASP.NET MVC work together to provide a great user experience and at the same time simplify your development task to pull this off. at Twitter.com/julielerman. Thanks to the following technical expert for reviewing this article: Vishal Joshi
https://docs.microsoft.com/en-us/archive/msdn-magazine/2011/march/msdn-magazine-data-points-server-side-paging-with-the-entity-framework-and-asp-net-mvc-3
CC-MAIN-2022-33
refinedweb
2,228
63.29
. Atomic CSS keeps things simpleAtomic CSS keeps things simple. –DealingA lot of people dislike it How is Atomic CSS different from inline stylesAtomic CSS vs. Inline Styles Atomic classes allow abstraction, inline styles don’tAtomicTooling Sass, Less, PostCSS, Autoprefixer… The CSS community has created a lot of useful tools that weren’t available for inline styles. BrevityBrevity Rather than writing out verbose inline styles, atomic classes can be terse abbreviations of declarations. It’s less typing: mt0 vs margin-top: 0, flex vs display: flex, etc. SpecificitySpecificityClassesLimitingAtomic. Atomic classes speak for themselves. Their intent and effect are immediately obvious. I’m not sure I would agree with this assertion. I think Atomic CSS (like most naming conventions) has a learning curve. The shorthand that Atomic CSS uses tends to reduce the declaration to as few letters as possible; if you’re not already familiar with the naming convention it may be indecipherable. Consider Bootstrap 4 and it’s utility classes for spacing: .mt-4, .px-2, etc, etc. For a person familiar with Atomic CSS these are clear and coherent because you already have context on which to base your interpretation. The only thing not immediately clear is what real value ‘4’ or ‘2’ translate to. For someone who hasn’t really been exposed to this naming style there is nothing immediately readable. I could forgive a novice for overlooking these completely and assuming they were generated by some backend application for secondary purposes like targeting elements by class. Agreed. What would you call a class for applying box shadow? I assume bs-… But then what do you call the class for border-style?? These convention systems are, at the end of the day, just conventions and at some point a team has to decide on them and no two teams will decide alike. The learning curve between this or another system doesn’t really seem any more or less difficult. I think utility classes need to very generic in use. The idea of .px-2 seems to imply a padding on the x of 2 pixels, or some other totally trivial style thing. In my experience, utility classes usually are best used in two layers. If they are part of a framework, they just affect very generic things, like widths, positions, layouts. And there are very few of them, thus limiting the learning curve. If they are part of a site style, then they are custom to the site, and therefore the learning curve is short because they focus on the needs of that current site. Trying to combine both general framework styles and custom site themeing into the same batch of CSS is, in my opinion, one of the extreme downsides of frameworks like Bootstrap and the biggest addition to the learning curve. But, in the long run, everything has a learning curve, and supposedly it should make development faster/smoother once past the curve. So ymmv in any chosen system. @travis In my own projects I tend to use longer CSS class names specifically to avoid this sort of ambiguity. To use your box-shadowexample I would probably apply a naming convention like this: And that first portion ( _ui-effect) would ‘house’ all of my design enhancements that were universal to the interface I was creating. For my purposes it ticks all the boxes: It’s clear what its scope is (UI), what it does (applies a box shadow), and can be combined with other classes to enhance whatever element upon which it is applied. Ok, so who else here remembers the days of CSS1 and (pre-x)html when tags were a thing. ALOT of work has been done in the last decade to improve the separation of concerns and DRYness of web languages. While I can see merits to this approach it feels like it flies in the face of of all the work that’s been done and ignores the whole point of modern web standards. I feel like the last subheading really is the proper use-case for atomic css – namely not as an overall framework, but rather as a tool to keep in our toolboxes for when we hit one of those inevitable edge cases that bloats your css. IMO design patterns are just that, patterns, and should be used and ignored with discretion and as the project deems it necessary. the days when *font tags were a thing. I should have previewed that comment, I forgot I cant use the angle brackets here I remember the font tag! Feels like there were two things going on. One was the need for utility type classes to position things that weren’t in the original design spec for whatever was being made. I get this, along with acknowledgement that sometimes a pattern may qant to flex, other times not based on its content. To actually build pattern designs entirely from these classes within the html though… That just seems clumsy and exhaustive. I’ve actually used the approach oncw this year on a project and found myself forever tripping over what a pd10 was. Was it padding x&y, just y, just x, was there now going to be a separate one for each? At that point I conckuded this was a really wasteful approach. Until, that is, I started using them as pure design utility to change the shape of a unique pattern. Problem then was its unique nature made me question where to use ID instead. If anyone disagree the uses of Atomic or Functional CSS, take a look and you probably aren’t aware it’s existed everywhere and part of it in Bootstrap. Kickstarter use it too. Use less naming unless you have to. No, it is not worth it. It might be clichè now to blame it on the millenials, but nobody in their right mind with a two-decade experience in frontend (when it was called being a webmaster), would resucitate the font tag as utility classes and call it an approach. Why would we sacrifice design consistency and semantics to follow what has always been a bad practice? We don’t need to go back to those awful places modern web standards took us away from. It’s like someone longing for The Dark Ages to make a comeback. I’ll give Atomic CSS adepts ~5 years to realize what a terrible mistake they’ve made. Then they’ll come up with a fancy name and a slideshow for using web standards as they were meant to be used. Semantics? What semantics? Yahoo! has been using this method for about 5 years and as far as I know they are not planning to go back to the old days of having to rely on over 100Kb of CSS for styling their pages. — a former webmaster I think the biggest problem with articles like this is that they seem to imply a dramatic shift in the CSS world, when in reality, they are simply describing a phenomenon that has already existed for years. I have “atomic” classes that just set defined widths, position inline-block, and a few others and that’s it. They are very useful in app environments, and I have had them for many years. But I am not going to move all my styles over to this. Also, I don’t use atomic style classes for actual visual styling, I think that is where your concern may actually be, and mature CSS devs won’t paint themselves into a corner no matter what the “trends” are. So, take everything with a grain of salt. These authors have to consider how to share information while both exclaim it’s virtues and not over doing the effects on the industry. But I think your comments are the sour to their sweet, it’s necessary for a balanced view. “Utility classes can coexist with other approaches.” This has been my approach. Generally I follow a BEM naming scheme, however there will always be a small collection of utility classes for one-off modifications of elements, ex, .mt-0 for margin-top: 0 !important; I just wanted to name drop a couple of frameworks that I have been experimenting with lately and see what others’ experience has been with them. : SASS based OOCSS framework And : PostCSS based utility class framework I’ve gravitated more and more towards PostCSS for projects, but iotaCSS has totally inspired me with its namespaced utility class names and responsive configuration. Anybody else use it? I also wanted to say that for the past year or two I’ve started nearly all projects following the structure and using BEM. This has you creating discrete components, but also has a folder for page-specific styles. Especially thinking about margins as with the example above, I’m not convinced that page-scoped styles aren’t an A-OK solution to slightly modifying components in different contexts. Keep the comments coming! I’m glad I work alone. I can use naming conventions I like, like calling classes pluto or martha. Please don’t do this. As someone who’s picked up code from another developer who did this… please… Sorry but not for me, I pretty hate bootstrap and this atomic thing …dirty code I keep coding css in my way I’ve been using recently and loving it (co-created by the same Adam Wathan you quoted here). I no longer hate CSS I think, if you’re comfortable using bootstrap, then you can write atomic CSS. But, if you want the classes to explain the content rather than the style, don’t use atomic CSS and bootstrap too. That! This is where tools like SASS, LESS, PostCSS can come into play. I initially started using Tachyons, but then wrote up a mixin that outputted the same pattern. Now I’m seeing repeatable patterns when creating components that I’m expanding the mixin to allow multiple properties. This requires discipline to not deviate too far from the method but still affords me the same flexibility and speed of coding, and finally the output size of the CSS file stays small. You can adopt concepts but do not treat them as a rule, let’s say like language functions. One more thing. !important in CSS, due to inlining or otherwise, even inlining alone… is one heck of a regression. It bothers me that either still come up. My guess is, if you’re writing a lot of css, you’ve already been doing this at least a little bit. I never had a name for it, but I’ve always had a small handful of utility classes that I’ve used. Just my own experience speaking here (not scientific, merely anecdotal): I use atomic css techniques (I roll my own: and I’ve been using them for about five years. I also use BEM names for some semantics, however I hardly have actual styling behind these classes besides some things at breakpoints. The semantic names are more useful for readability and easy selecting of code. In my personal experience using these techniques I haven’t had to deal with any of the traditional pitfalls of css. Additionally, team members, even when skeptical at first, try it and start using it on their own projects. One important experience I have with atomic is that there are people who hate it a lot, and seem to go out of their way to make people who use atomic feel like they are inexperienced and that in the past lessons were learned and now inexperienced developers are making the same mistakes again. I often don’t think this is put as sensitively as it should be for new developers, nor do I think it is true. I use atomic css and I’ve been making websites since before CSS was available (bgcolor=, etc), and I’m sure this is also the case for many others who use atomic css (or styled components, and so on). I’m sure there are new developers trying atomic css, and I don’t think they need to be talked down to. For a framework, sure it works, for a website is a fickin mess Chris: “For a framework, sure it works, for a website is a fickin mess” Not for TED site who uses their own Shed CSS (Atomic based) libraries. Sure you have heard TED Talks? You fluffed an old joke: there are only two hard problems in computer science: when to clear the cache, naming things and counting items in a dynamic list. Using it with great easurw for the last 3 years basscss No, no. no! The one good thing of this article is that it states clearly what are the drawbacks of Atomic CSS. Styling a page is trying to translate a design into code. Of course you apply a certain margin here, a padding there, a font-size in another place, etc. But if you really want to translate this design, you may give a class to a “box” and in this class, apply many different attributes: margins, paddings, borders, font styles etc. And this gives you the idea that design is not just a margin, but a collection of things. Some people say BEM is ugly because of lengthy names, and repetitions, but if you use only atomic classes, its so much worse! and when you read the collection of atomic classes, you have to read every single class to figure out what is applied at the end, and maybe know the website to realise that, Oh, on this particular block, we don’t apply this margin that we generally apply everywhere. When with BEM you would probably have one class, and a modifier saying “particular situation” to handle this difference. But I agree that “utility classes” are actually usefull sometimes and can definitely make use of “!important”. But you should almost always be able to do without. At least you should try ;-) Atomic CSS does not necessary mean having a finite set of classes/rules. There are static solutions (a couple are mentioned on this page) but there are also dynamic ones (i.e. ACSS [1]). Static ones come with more bytes than needed; some may also impose the exact same styles across projects (eg. when their arbitrary values are not meant to be changed). On the other hand, a dynamic library does not limit the styles authors can use and comes at no cost in term of performance since it automagically creates/deletes CSS rules “as you go“. Like everything CSS related, both of this approaches have their pros and cons. [1] I’m looking forward to see how Atomic CSS authors deal with the Grid spec. I cannot see it working. Maybe with floats, and Flex-faux-float-grids and col-xs-whatever but not Grid, not without limiting it’s capabilities. So, I am big believer in the right tool for the right job. And I honestly can’t tell if zealots are wrecking good ideas used improperly, but I think most CSS techniques overlap and have special use or general use cases, but rarely (or never) both. Here’s a general approach to Grid I love. But I don’t use it everywhere, I use it very controlled environments with lots of form layouts that benefit from this. Utility classes for Grid. Example of use in codepen: It’s useful for form construction mainly. I haven’t used it for much else. But I can’t say if this fits “atomic css” by definition, but it seems to. And I certainly can’t think of an easier way to do this using any other methods. Any reason this doesn’t work from your opinion? I imagine Grid can be seen in a different way to what has come before. Methods that describe the utility such as col-2fr are bound to fail, for instance what happens when a utility for a row/col combo in a specific co-ordinate on an implicit grid is needed? Grid has huge potential, however it will be limited by the imaginations of it’s users. I wrote quite a bit about it here if it’s of interest to you. Then you make something that fits the requirements. But that doesn’t automatically mean that all the situations that are solved quickly and easily by a utility are invalidated. You seem to be falling into the common trap that every solution must be universal and perfect, and that’s how we get holy wars. Use the right tool for the job. Utility classes work wonders for most common needs cases, not custom needs. Arguments against utility classes on the basis of edge use cases fails a common sense approach to problem solving. I think this will get solved over time as we experiment more with grid itself to begin with. Even if it isn’t solved 100%, that doesn’t prevent using a combination of atomic and some other methodology to use grids to their full potential. Perhaps atomic will be able to handle the whole thing, but I suspect that I’ll be using atomic for common cases, and falling back to my BEM classes when things get more complicated (or if the api for atomic css would be too difficult to learn). IMHO atomic css concept is very misunderstood. When i first time saw the syntax i was scared… by the time i realized its easy to remember name of utility clasess… Most of atomic haters overview the fact u do not use atomic for styling every element with 20 classes. I find very effective to define generic base styles (typo, colors ect) styles used across the project… and in some specific scenario u can apply UTILITY classes… to be honest get desired state in like 2-3 classes at maximum…so ur html isnt growing much… This is one of those tabs vs spaces things. I personally do a heap of this in my css red-text, blue-text classes etc. Same if you have 3-4 font sizes etc so <h2 class="red-txt alt-font-a ft-sz32">to me is a simpler way to see the CSS. Clients like it too, if they need to see the CSS in the HTML editor in the CMS it is quazi English. I went to college with a lad who would write bizzare things in the classes to keep himself sane. Classes like sideshow-bob I dont think there is a right answer assuming your not writing terrible code. I’ve tried working like this in the past, mostly with framework classes from Bootstrap. The reason I gave it up is because of style leaking. That is, my classes clashed with each other. One would inadvertently influence another on a child element and throw off the layout. It got to the point where I was reading through the HTML to figure out how the classes combined to produce the wrong layout. My preferred solution these days is tightly-scoped CSS based on Jareware’s CSS Architecture rules. Related articles lately: After building a website using atomic I came to the conclusion that it was hard to maintain and confusing. Every time you looked at the HTML you’d have construct a model of what each element was supposed to do. Mobile overrides were frustrating and led to bloat in both CSS and HTML. After some tinkering I came to the conclusion that a hybrid approach is possible. Take for example centering something vertically in a div. Here’s the classic way of doing it: The hybrid approach is to abstract the part that does a function and recycle it in your HTML anywhere you need it. The question is what to treat atomically and what to treat classically. I want to be open to this approach, but pretty much all my work, ever, has been on building web applications whose markup I control but whose styling I don’t control. In other words, single codebases that get used by many companies, each with their own themes (sometimes developed by third parties). It would be an absolute nightmare to have a separate HTML template file for each client just for the sake of changing the atomic classes. There’s often a lot of logic, accessibility markup, or metadata in the base templates; it’d be a maintenance headache to go into each client’s theme folder to update the templates if you ever needed to change your approach or change the data model. It surprises me that nobody talks about theming. For this use case, it seems that the approach that CSS Zen Garden made popular is not only the only tenable approach, but the only possible approach. Thanks for bringing this up. I think the type of work one is doing, as well as the kind of company one works at are important factors in whether atomic css is going to be a good fit. If I wasn’t implementing the look of a site it would basically be impossible to use atomic css. That would include if I was implementing something that would then need to be re-themed later. A few years ago I heard a few people debating whether we should focus on re-usable css that can be applied to a variety of markup and make it all look consistent versus re-usable markup that can easily be restyled. I never understood why they chose whichever path they chose because nobody ever described the reality of the projects they were working on. I suspect they were all webdev bootcamp students who had yet to build anything really complex. How long will it take until Atomic CSS will be discarded as what it is? A terrible terrible Idea! In a few years everyone will be hunted by this very bad approach. I’m a designer working with a lot of backenders. Those poor souls don’t have to endure these kinds of css class madness insider their html markup. They need to add simple css classes which I then can target via css. Separations of concerns? Do you speak it? The only good thing about Atomic CSS is it’s name. While the context you speak of may be true (may not, depending on what the poor backeneders like doing), not everyone has a different team (or even person) to implement css and the html. I use atomic css and I write both the css and html for projects I work on. Maybe if you’re working on a project you prefer using another approach, but I don’t see how this means that atomic css is a terrible idea. Care to explain more? The class=’color-dark’ breaks down as soon as you’d want to implement a night-scheme parallel to the normal one. I think this technique will very easily miss out on the adaptable possibilities css gives you, like media queries. (But also on the quirks of css – it shifts the desing over onto the writers of the components / html which may or may not be a good thing.) There may be some benefits to this in certain cases, but I do not think it will lead to the best, most adaptable or most maintainable designs overall. As a user of atomic css I’m interested in this maintainability question. This is because I switched over to atomic css (probably about 5 years ago) to avoid maintainability issues, and I haven’t looked back. It seems that there are different kinds of maintainability (and maintainability of different portions of a project). Then there are certain problems like: Client has a component, and now they want to use this component someplace else – oh, but in this case we want it to be different in these subtle ways. Without atomic css you will probably have to update css and html, whereas with atomic you will just need to update html. For both approaches you will have to pick between adding conditional logic, or duplicating code (or a combination?). With duplication of css (which all goes in the cascade) I think you introduce a greater risk of bugs, also the cascade doesn’t make doing conditional logic very easy (compared to if you’re using a html templating library, or a js framework like react), and the way you ‘read’ the conditionals in css isn’t obvious for future maintainers (you basically need to depend on naming conventions). I always use a mixed approach depending on the needs of the project. If a project requirement is that a site needs to be able to be themed, then it is also necessary to determine the extent of the theming. If the themeing has to be as extensive as css garden (where basically everything but the markup can be expected to change), then I would use BEM (or a similar approach) to class names completely. On the other hand, if only the colors and fonts (including font-size) of things would have to change, then I would use BEM along with atomic css. To take a third case, if in fact there is no themeing for a project (which is frequently the case for me) then I will create BEM class names for semantic reasons, but really the majority of the work will be done via atomic css. While these are the approaches I’d take, I think the last one would probably have the lowest cost for maintenance on my particular team. What do you think? What context differences may change some of the answers you’d give to this stuff? Why not just @extend %placeholders in your SASS/SCSS? They can be atomic. They can be reused. Best bit: they don’t litter your HTML, thus you can continue to keep your styles and structure separated! Yup. Keep them separate. Atomic css in HTML across multiple (>2) breakpoints. Good luck with that. Absolute nightmare. How about SASS with includemedia? You can also use includemediaexport to get access to your breakpoints in JS. I wonder if there are only two styles on CSS: doing the work of designing a grammar and language for your product’s (style) needs specifically, indifferent to whether this way of speaking can be translated to other products, or, trying to solve more than one persons/company’s needs. Atomic CSS works well for the first case. Maybe I’m not sure what you mean by the first case. For me atomic css sounds like (and in practice has been) an approach I can indifferently apply to any project I work on (be it a website or an app) that uses atomic css (the css is portable). Something like BEM – as a design system – also is applicable to every project. However, whenever I move to a new project I always end up writing a new set of bem classes (the specific css isn’t portable). In practice I find that both of these approaches are useful to use at once (some portable css and some non-portable) If I’m building one-off application that only has to make sense to my local team, and we have been careful in our branding, product design and visual style, and have a clear idea of all the visual terms that will need to be presented (and hence styled), how they are grouped and relate to each other can be planned using a grammar that only we need to understand, and atomic CSS will likely make sense there, benefiting from the simplicity and lean-ness of avoiding the redundancies/generalizations of “for everyone ever designing anything” style strategy. atomic css bloats your html, and it is almost like writing inline styles… I rest my case. Web component’s approach is much more readable – even if you don’t use web-components. custom tags (without upgrading to custom-elements) are displayed as by browser and they are supported back to even IE8. example: css: Another approach is to use [role=”side-menu”]. This way chaining roles makes your css both readable and your HTML ready for automation tests even when you move things around. I cut my teeth in the days of bloated tag soup HTML. I was very resistant to Sullivans’s proposals for OOCSS because of the clutter being reintroduced into my markup. I later came to the realization that markup does remain pristine forever. Redesigns will often require one to change and adjust the markup so relented to the idea that having numerous classes to apply styles was not such a bad thing. Now I look at what some of our React devs are doing just to create a box using Tachyons and I can’t help but protest once again. How is it better to style a box with 16 class names setting things like margins, paddings, dimensions, positioning, border, border radius, box shadow etc. better than using one class name that sets the same styles? Perhaps our devs are taking things to extremes but I foresee a lot of pain in the not-too-distant future when a new redesign comes along and those hundreds of components will need to be modified to accommodate the new design. I meant to say that markup does not remain pristine forever. It’s kind of funny, I see the argument made for Atomic CSS because “I noticed I was writing ‘margin’ a ton in my CSS so making it one class just makes sense!” – and then they end up with the same amount of ‘m-0’ classes in their HTML. I love reading everyone’s thoughts and opinions on Atomic CSS, when to use it or when not to use it, ect., and I’m not even sure myself if I could use it on a project fully from start to finish, I’ll have to try it and see how it goes. I do see advantages of quickly editing one element, but then global changes could be a nightmare unless you’ve set it up component based, would would make the most sense. I want more articles and discussions on it, from people who use it on the Yahoo team, and why it was done for such a large site and team. And this is exactly where I think Atomic style classes are used improperly. I don’t think they have any value in styling content this way. I think atomic classes are great for utilities, not design. This would solve the issues of massive style changes affecting random parts of the site. But consider an atomic class to create simple columns, opacity hover effect, icon systems, etc… I don’t see there a pain in TED site and Yahoo where they used for years. TED ( created their own Shed CSS and it looks great on their design. James, are you really pointing out TED’s Shed CSS ( with over 7,750 !importantstatements in their colossal, unreadable, code… as an example of how to do CSS? For people that want to learn or improve their CSS, and how to optimise maintainability, these are not good examples at all. I don’t know how Atomic CSS can consider itself beginner friendly, because I would not use that horrendous result in my training materials. If HTML has class names that are essentially shortcuts for inline styles, then it’s wrong, and I don’t care how popular it is becoming. Atomic CSS also calls itself lean, because it only includes the styles that are actually used in the project. I cannot write class="js-stream-ad-noview js-stream-ad Wow(bw) Pos(r) Mx(a) Mt(-1px) Bxz(bb) Bgc(#fff)"and think ‘yes, now I’m getting somewhere, this is so much leaner!’. Looking at the ‘successful’ implementations in the wild. It’s not lean, it’s huge, and so is the HTML that uses it, saying Atomic CSS has ‘no bloat’ is an outright lie! I’ve never seen HTML or CSS so ridiculously bloated in my 15 years of full time web development. Another thing I worry about, with all this promotion of architectures and frameworks based on their popularity… I did a lot of recruiting earlier this year, for my own development centre and also for others. We were looking for highly-skilled front end developers, capable of helping resource any project in a multinational consultancy firm regardless of framework or architecture, so core skills in HTML, CSS and JavaScript were highly sought after for this recruitment drive, fluency in all three was essential. Front end developers with a preference for CSS architectures interviewed terribly, (even worse, a preference for application frameworks like Angular or React) they had insufficient depth of knowledge even in the fundamentals, and therefore lacked the versatility we needed to be able to place them at our client locations. You would think experience of a ‘popular’ framework, library, or architecture would look good on your CV, but after a few months we discovered the opposite was true. For such candidates, we could predict the knowledge gaps, and save ourselves time in the technical interview by asking those questions first. What’s the most important thing about making web pages? The HTML. The HTML will make or break your site. Keep it simple, use the appropriate elements designed for the task. Congratulate yourself on avoiding the majority of accessibility issues. Does your site still function without the JavaScript? How does it look without the CSS? If either of these experiences are impossible, then you have designed your website to please the wrong person; yourself. Back to HTML, the most important thing. Do you ever validate it? Is validation part of your development life-cycle? Why not? The W3C validator can be downloaded as an executable JAR, it’s easier than it has ever been. Let’s assume you want to reliably produce valid HTML. How can you generate valid HTML so reliably even in large volumes? Well, you sure shouldn’t be hand coding it. I don’t. At the moment, I’m using markdown for most website copy, and for more complicated components, like forms, I have components that procedurally produce the HTML in a consistent way. The whole development process is intentionally constrained to produce uniform HTML, I deliberately have minimal control. The power of CSS is that you can apply styles to your web pages consistently, you can have multiple visual designs without making a single modification to the HTML. Redesigns and rebrands are trivial. Therefore, Atomic CSS has no place (and neither does BEM, or any other form of classitis). CSS has great power, yet so many use it with gleeful abandon of responsibility. Atomic CSS is not simple. It makes well-crafted HTML impossible. Keep it simple. Can you show me a simpler way to make a two page layout than this? I could then use this same class anywhere I want two column anything. How is this not simple? And does it make the html it’s applied to impossible? It really seems that Yahoo and other people are going crazy overboard with their use of atomic style class usage, and it’s obvious that this would complicate things. But when used “simply” how is it not simple? You should avoid class names like grid. You’re putting visual design decisions into your HTML, where they don’t belong. What if tomorrow you don’t want a grid? What if it’s only a grid when on a maximised desktop, or landscape mode? It’s a bad class name. The class attribute is for author classification of HTML elements where the semantics of the elements or attributes alone is not sufficient. I am reducing the number of new class names I use especially since new HTML5 elements and ARIA roles provide more universal semantics. For a page layout. My HTML design would be something like: If I wanted that page to be two columns, the CSS would be identical, but without the class selector: I’m trying to think where I would definitely know for sure I wanted other areas of a website to be two-columns. Maybe definition lists, then I would want all definition lists to be two columns, given that consistency is probably desirable. Hmm. I’m more likely to have a reusable way of displaying fancy listings, where each item has a border with a drop-shadow or something fashionable, and I would like similar styling for lists of products, users, appointments, whatever. I would usually do something like: The reusable listing styling would be applied using the .listingselector, and any styles specific to product listings, would be applied using the .productsselector. Sure, class="grid"looks tempting for reuse but it’s actually an anti-pattern, because you’re embedding the currently-desired visual design into your HTML. Which would be really bad, because there tends to be no such thing as a permanent or final visual design. I’ve been on a few sizeable re-branding projects for companies that changed ownership, merged with other companies, or were just migrating old systems to their new, modern look and feel. These customers needed wholesale look & feel changes to their websites and web applications, with minimal risk to breaking actual functionality. The systems with the most semantic markup were the easiest. I remember one particular project where the HTML was coupled to the visual design we considered it impossible to achieve the redesign without overhaul of the actual application, at an unacceptable risk and expense. Suppose some of the situations where you used class="grid"are no longer required to be grids? How are you going to identify all the instances of class="grid"that are to be changed and those that are to remain unaffected, if the HTML hasn’t been semantically written? You could be lucky and only have 20 instances of class="grid"in your entire code base. That’s probably a manageable amount of analysis to carry out. But what if there are 200, 2,000 or 20,000? It’s never simple to embed your visual design into your HTML. I like this. How are you able to achieve this? Vanderson, your particular grid example is only 5 lines of code. I’d rather use multiple selectors in only 1 place in the css or even duplicate those sames lines in multiple places (via mixins) over using .grid in several places in the html. But that is only my preference based on the 70+ projects I’ve worked on over the last dozen years because most of those projects needed to be done fast and the fastest solution for us was to re-use pre-existing html and just restyle it. I’m not saying my way of working is better than any other. That is the problem with all the articles like this. Somone had a super hard job and used a technique that worked well for that case and then proclaims everyone should do everything their way on ever project. Ignores the fact that everyone’s reality is different. What is best for Yahoo might not be what is best for Facebook. What is best for Google might not be what is best for Twitter. What is best for Twitter.com (does not use Bootstrap) might not be what is best for Twitter’s internal corporate applications (does use Bootstrap). What I wish articles like these would do is say “If your situation is this and this and this, boy have I got a great suggestion for you…” Hey Rob, Well, it’s all custom written, it could be in PHP, Java+Spring+JSP, Scala+Play+Twirl, Node.js+Express+Mustache, anything! As a simple example, to add a form to a page, I only need to author: Which is kind of constrained to: Label: [field type](validation rules) [Submit button text] When creating a form for your web page, you should only write a simple, bare minimum specification of that form, in my opinion. How that specification is converted into HTML is a development issue, because it should be automatic, not manual. There really is no opportunity to introduce dozens of custom classes to the HTML generated from that. But that’s how I like things, every form within a website intentionally has consistent layout and style, since we regard consistency to be a good thing, and so do our users. If there is a good case to have a form on the site that looks different from the others, then the element containing the form would be a good thing to use for the distinction, in the CSS rules. For example: So, I solved the problem with a descendant selector, as an example, but I think that’s quite alright, because I’m using CSS! – Unlike CSS ‘architectures’ (or as I like to refer to them, CSS avoidance schemes). I completely agree that you should not put “visual design” in your html. It’s a class name, not inline styles. You are arguing against inline styles here. (ie, React) I will repeat old, old wisdom, use the right tool for the job. Just because you can’t see a good use for it doesn’t mean there isn’t one. I’ve been doing this for many years now, and I have seen multiple times what was once the written in stone rule “never do this”, get’s repealed later. So I stopped listening to dogma like this and I use the right tool for the job now. When was the last time you saw a menu in a Windows or MacOS app have to completely alter their layout of drop down menus? See, there is a place for a class called “menu”, because there just are universal things that can gain value from this long term design processes. Also, I didn’t name the class “grid”, I just did that for simplicity of example, perhaps it triggered a holy naming war here. Would it matter if I called it “2-colum-thingmabob”? Consider the CSS zen garden, not every project has the budget or the long term goal of perfect theming, nor is that even in the specs. Sometimes in seems that discussions like this devolve into how the perfect CSS should be written, and any practical methods are shouted down because of potentially blind zealotry or just your “personal experience” says it’s bad. Inline styles were “evil” not long ago, and this site, a bastion of knowledge on CSS on the internet seems to fully support it now. So, I say, ignore the dogma, zealots and ideology, and use the right tool for the job. Find and replace. It’s never been a problem. I’ve worked on multiple hundreds of thousands of lines of code. Hundreds of websites sharing libraries. Data with content in it. It’s just not that big of a deal. If there’s a budget, it get’s changed no matter what. If not, it gets lived with. Easy peasy. Also, years ago I learned a lesson from a guy that owned a company that made software for military satellites, massive projects, and he said every so many years, they just had to scrap a lot of their code and rebuild things. You can only tweak, repair and manage a system for so long before having to start over. If you’ve ever worked on a big enough project for long enough, you will see that no strategy is perfect. Everything needs to be redone. Sure it is. It all depends on the specs for the project. Surely you aren’t claiming that .grid is a horrible class name for a one page website for my brother’s dog? That’s absurd, who gives a whip what class name is used there? So your critiques must be classified as only relevant either to your experiences, your work style, or projects with the types of clients you work with, etc… Being absolute about a naming convention (which is all that Atomic CSS is) leads to a form of self imposed blindness to the right tool for the right job. I would defer to your judgement whether or not it would work for you in your projects. But it doesn’t mean it’s not the absolute best and perfect solution for others. @Vanderson, I think we are talking about completely different things. I’m talking about the value of well crafted HTML and how that’s incompatible with modern ‘CSS avoidance schemes’. I consider writing inappropriate HTML impractical, and I have outlined the main reasons why. If you think in some cases, the cost of impractical HTML is bearable, great! If you think that such schemes are actually practical and preferable, then we will never agree. If they’re the right tool, somebody somewhere is doing the wrong job. I would rather USE (not design or develop) a site with well crafted HTML, for example, where a drop down field was actually a SELECT element and not some half-baked JavaScript-dependant widget. Why does it matter? Because I’m so fed up with using websites that are broken because they didn’t keep things simple. It happens far too often, usually when I’m registering, booking or paying for something, i.e. actually trying to get something done in real life. Incidentally, Internet Explorer changed their drop downs in IE10, nothing drastic, but enough for people to notice… for the benefit of touch users, apparently. So it happens, and if you stick to appropriate HTML, your site will automatically pick up such enhancements. I was arguing against everything visual in the HTML, not only inline styles, class names like “grid” or “2-column-whatever” are equally inappropriate. “menu” is fine, that states what the structure is, without saying anything about how it will be visually represented, so I’m afraid I have no objection there, but it seemed like you thought I would? I’m often working on projects where it’s unavoidable to use some form of layout markup, I’d rather be embarrassed and apologetic about it, than to convince myself it’s perfect and the best thing since sliced bread, otherwise you will never find a better way. I don’t care what people do on their pet projects, indeed they can do what they like. But I do care what people evangelise on popular educational websites, whether promoting techniques that are responsible for poor user experience (e.g. inappropriate HTML), or may lead to code that’s difficult to maintain, long term. No, you cannot simply search-replace class="grid"if some of them need changing and some do not. Each particular match requires independent analysis to determine if it needs to be changed. It’s an unnecessary cognitive drain, the larger the set, the less manageable it becomes. Having the budget for fixing the technical debt which is no fault of the customer is where businesses fail, long term. If a customer doesn’t have the budget for their trivial design change, you will lose that customer. All it takes is a competitor to explain how difficult it is to maintain things built that way, and before you know it, you have a reputation for being too expensive, not building things properly (cutting corners), or too slow to react to simple customer requests. And your competitor will be the one doing the scrapping and rebuilding, not you. Yes, of course my critiques are based on my own experience. As it happens, I’m currently working on such a rewrite project we have taken from a competitor, so it’s no wonder, really! It seems like for the past 6 years the conversation around doing css right has been dominated by a small elite group of people whose use case tends to be a single design language (that is constantly evolving) spread over less than a dozen very long lived products with large teams and large budgets. I clearly see how certain techniques benefit the likes of Twitter, Facebook, and Yahoo. But where are the css experts from small agencies where every week is a brand new project (or a brand new skin over an existing product)? I need to hear about what is working well in their workflow because they do what I do, what most of the world does, and most of us will never work at the likes of Twitter or Yahoo. Well crafted html is not incompatible with anything. There is no such thing as inappropriate HTML. It’s just a markup language. If your experience compels you to write things in a certain way, by all means do so. But to declare your beliefs as the one true way for all the billions of html documents ever created or ever will be created is an absurdity. I applaud your desire to be a great craftsman. But not everyone can make masterpieces, some of us paint houses. And doing the less glamorous and perfect work is an honorable living. If you think so, you should read the spec. Everything else is inappropriate. You couldn’t be more wrong. The difference between being completely wrong and completely right is only one word. Delete „just“ and there you go! ;-) @Lee Kowalkowski Classes have nothing to do with HTML per se. Those are strings inside an attribute. Regardless of what one chooses to include in there it will not create “inappropriate HTML”. What is impractical? If it is deemed preferable by authors then it must be “more practical” – at least to them (please see my point below about the user). Classes don’t create broken experiences, styles do. “menu” is fine but “grid” is not? Why that? Could you point me to some specs/recommendations/articles that prove it is best practice (not common practice) to use semantic classes? When it comes to CSS there is no one-size-fit-all, no best method. It all depends on the project (its requirements, the teams involved, etc.). Poor user experience? How so? Once again, classes are meaningless for the user; all that counts are the styles attached to them. Nowadays, with components, changing styles does not mean changing many classes across a code base; and that’s even more true with dynamic Atomic CSS libraries (à la ACSS) or with custom properties. Incompatibility is bidirectional, but if it was directional, then no, well crafted HTML is compatible with everything, that’s my whole point. Absolutely there is such thing as inappropriate HTML! Only today I overheard a developer ask about styling a button to look like a link, the CSS he was given provided classes to do that but he was struggling with the alignment. This is not OK. A button styled to look like a link will never have the same context menu as a real link. You can’t right-click these pretend links and ‘Open link in a new window’ or ‘Copy link address’. Expected behaviour is missing. Opera has different keyboard shortcuts to navigate links than buttons, pretend links are unexpectedly skipped. Screen readers have the ability to generate a list of links found on a page, for quick navigation, pretend links are absent. The CSS provided a way to style buttons to look like links, this is a good example of having the right tool for the wrong job, and why ‘visual’ class names are just as inappropriate as inline styles, and since class names in the HTML and only referred to by CSS, it’s the HTML that’s inappropriate. CSS has the over-abused convenience to select elements based on class names. The misconception that class names are synonymous with style is the root cause of the problem. Since selection by ID has long been out of favour, classes are the new ID, in specificity terms, except classes are more versatile than IDs. Because of this, we find ourselves arriving at unmanageable HTML/CSS in more varied ways. The ‘innovative’ solutions seem to have overlooked the fact that we are victims of our overuse of class selectors, so they fail to actually solve any problem, they only shift it. Nobody should think it absurd that I recommend using HTML in a way that doesn’t hinder user experience in unanticipated ways. I strongly feel it’s the developers doing the ‘less glamorous’ work that have the most to benefit from ignoring whatever is fashionable or popular, keep things simple and stick to what works. @Thierry Koblentz …then you don’t understand the word ‘class’. I’ve already covered what classes are for: The class attribute is for author classification of HTML elements where the semantics of the elements or attributes alone is not sufficient. Again: If the HTML needs revisiting because you want it to look different, then, in (not only) my opinion, it’s inappropriate because the author-classification of the HTML elements shouldn’t change just because the look and feel does. I was not talking about classes or styles, but inappropriate HTML in all its forms. It’s the needless complexity that creates broken experiences. Menu does not imply layout, it will still be the menu if it is pop-up, pull-out, horizontal, vertical, anything, it’s a menu. Grid implies layout. I bet in a good responsive layout it would at some threshold cease to be a grid. Grid is not what the thing is, so it’s not the class of the element. So why is it a grid? Let’s suppose it’s because it’s a calendar or gallery, then the class of the element would be ‘calendar’ or ‘gallery’, not ‘grid’. The best practice is called ‘separation of concerns’ – there are countless articles and recommendations about why it’s best practice, use Google, not me. If you have to modify your HTML to change its style, you do not have good separation of concerns. Indeed, yet I’ve worked on many different web teams for decades, and web developers that work equally confidently with both HTML and CSS are surprisingly rare, and another reason why the separation of concerns is important. Web application developers are users of the CSS, they are the true consumers of the CSS architecture. They need to produce HTML that is compatible with the CSS. In this sense, if you think classes are allowed to be meaningless, that spells disaster. It is not appropriate for a CSS developer to offload the difficulty of their job to the HTML developers and burden them with unnecessary complexity. Especially when HTML developers tend to outnumber CSS developers on a project. It’s not productive to make the wrong people do the hard work. The team structure I’m currently dealing with consists of several dozen projects with several hundreds of web application developers, distributed in offices across the country. I am just one of those web application developers. There is small, virtual team of about 4 designer/developers that are responsible for governing the front end coding standard across all teams, they maintain the CSS, and ultimately, therefore, determine how the HTML needs to be written. I have little involvement with this team, other than the fact that I have to use their output. So my arguments are in the context of the poor HTML author that would be inflicted with bad naming conventions, expected to produce meaningless meta-content just to get their web application looking acceptable. The CSS developers would have done a neglectful job and failed to understand their true audience. In traditional web development, the CSS developer needs to own the burden of making the HTML author’s job easy. Even if they’re the same person; anything that works at scale should still work for small cases. Meaningful (or semantic) class names are more easy to understand, code review, search, remember, communicate, predict, document, everything. If you think this is only the blinkered opinion of a lunatic HTML developer then I despair for the future of our kind. This is absurd. Changing styles should not mean changing ANY classes across a code base at all, this has been the case for quite some time, not just nowadays, not even with components. I’m not saying it’s avoidable, but the risk of it happening should always be considered and avoided if forseen. It’s less true with Atomic CSS, you cannot change the look and feel of any element without changing its class. @Lee Kowalkowski Hypothetical Situation: Change a gallery from a row display to a grid display. Atomic CSS method: Change or add class to “grid” of a parent DIV on the gallery on the page. Your suggestion: Change the styles for the class “gallery”. What happens when you have 10 galleries on a site and they all have to look different? I deal with this regularly. Atomic CSS to the rescue. Easy, simple, 1 class name change and done. Yet, you suggest we don’t touch the HTML to keep it pure? Maybe I am missing something. Sometimes, and I am getting close to saying most times, a site is small enough that there simply are no issues with overlapping concerns. It sounds pretty clear you work on big multi-person teams with large sites on large code bases. Where my group works on very small to medium size sites with 100 pages or less. With maybe 10 pages of html templates with few class names in them at all, the rest is content from the client or modules with mustache templates. You are working on Porsches and Ferraris we are working on commuter cars. To declare that we are required to use the most advanced long term approach with the most costly method of building is simply wrong. We can use a bolt instead of a rivet, we can weld where you would glue. We can use aluminium where you would use carbon fiber. Where you have a team of people with separations of duty for a project that spans months. Our site is due in a week, and we have 3 people to build it. Now, tell me I need to hire a dedicated CSS and HTML dev, when there are people that can do both perfectly fine. It’s likely your business spends more money in meeting time then ours does building an entire site. Sorry, you are just wrong to think your ideas are universally true. They may be great and perfect in your world. But Atomic CSS is the absolute best solution for many cases for us. And even if the the class is “grid” and shows up as a single column on a phone, it’s still a grid. Just a grid with 1 column. Or are you saying there is no such thing as a 1 column grid? @Lee Kowalkowski That article you link to is over 6 years old. I have a more recent one for you to read: @Vanderson I already covered that! class="shoes gallery" class="coats gallery" ..., is one approach, another would be to have page-specific CSS, depending on convenience. I’m not sure satisfying a customer request that may result in aesthetic inconsistencies is always in your customer’s interest. Dealing with something by ‘just doing what the customer asked for’ can sometimes actually be failing to deal with it. It’s easier if you can persuade your customer to consider a user-centred approach (assuming users prefer aesthetic consistency). Never be afraid to offer advice – customers really appreciate it. Well, I had a real customer request once, on a personal side project (whole website is less than 10K), when users signed up from a partner site, they wanted the look and feel of the sign up process to match the partner’s brand. When they signed up from another partner, it had to match their brand instead. Today it now supports 12 different partners, each with matching branding – yet the HTML is not different at all. Keeping things simple, having separate concerns, works at any scale, there is no project too small, you can’t have workflow issues from following best practice, because if you did, then it’s obviously not best practice. I see it the other way round. We are working on the commuter cars, I mean, mass production of boilerplate services, division of labour by specialism. This is deskilling because it results in many developers with limited HTML skills and no CSS skills. The HTML patterns are dictated by the very few CSS developers. It’s very much a production line environment. These economies of scale forbids costly methods of building, every large global outsourcing company is only interested in reducing time to production and increasing shareholder profits, the only measure is man hours. There’s no place for costly methods, it all has to be streamlined otherwise we miss deadlines, incur penalties, lose business to the ruthless competition. I never said the CSS and HTML developer cannot be the same person. I also have side projects as a one man band and small teams, we organise hack days regularly for example, and the same ideas work equally well. I haven’t experienced anything that disproves their universality. I’ve seen many frameworks and architectures marketed in the past, all starting from the premise of solving problems that usually only exist in bad implementations. When there is anything good in a framework or architecture, it tends to get incorporated into a standard with native implementation soon after. I don’t see anything in Atomic CSS that is a likely candidate for standardisation, and I see no support for Atomic CSS among the people working on the relevant standards, but I have seen quite a lot of opposition. More like years, even decades, when you factor in support contracts and maintenance. This is why we cannot just ship something out the door and forget about it, and why the approach is important. There will be people with a wide spectrum of abilities revisiting the code in such systems for the unforeseeable future. The income from maintenance and support is more profitable than initial production, if you use a flexible approach in the first place. If you’re in the business of build it, ship it, take the money and run, there’s no need to champion against best practice in public, just get on with that. A grid of any dimensions is still describing layout and giving no meaningful substance to the nature of the content within it. @Thierry Koblentz So? Does good advice lose value over time? Do we also need to stop believing Pythagorean Theorem? It’s ancient! There must be a better way by now! Oh please… Either you didn’t read the article past its publication date, or you didn’t find anything else wrong with it. I’d already read your article, as it happens, and I found no counter argument. I don’t know if you’ve noticed, but you have no evidence that semantic class names are harmful, a terrible idea, and to be avoided at all costs. The part about restyling needs fixing, if you think restyling is limited to yesterday old style, today new style, then you missed the point. Restyling means it’s possible to support multiple styles simultaneously. The ‘nobody ever needs that’ argument doesn’t fly. Print Style Sheets? You also assert that BEM is popular (it isn’t) and use that as proof! That’s the problem with those of us that are too immersed in our own industry, we are subjected to most of the marketing. Popularity is only proof of marketing. Are all number 1 songs timeless masterpieces? Unfortunately not, despite being the most popular song at the time. As a HTML developer on the receiving end of a CSS designer that once decided to ‘try BEM’, as soon as he saw the HTML developers’ reaction to what was now expected of them, he realised what a bad idea it is to over-classify the HTML. Making life easy for the wrong person; himself. CSS design is like designing an API. Whoever is authoring the HTML needs to use the CSS design’s ‘API’. Unfortunately it seems a lot of CSS developers also author the companion HTML and are therefore oblivious to this distinction, and will never reap the benefits. Why would you make such a terrible API to work with? Because CSS is painful? To keep the CSS lean? To simplify specificity? These are not responsibilities of the poor HTML author in the same way as you wouldn’t design such a poor API. @Lee Kowalkowski An advice—no matter how good it is—is not the same as a theorem, isn’t? You may want to read about a fallacy called “Appeal to Antiquity / Tradition”. Anyways, I’ll stop here as I believe you think I’m arguing to convince you that Atomic CSS is great and that the SoC principle is harmful when in fact I’m not. Honestly, I really do not care what you think, what I care about is that people who read these comments understand that most of your arguments are baseless and that they should not rely on any of that to make their own opinion. @Chris You may want to check Atomic CSS on steroids; but in short, we had 2 main goals: limit bloat prevent breakage Bonus: the approach allowed us to share components sans styles sheet attached! 5 years ago we started with a static library (like what Tachyons does today). It dramatically reduced bloat and sped up development (2 big wins) but devs were frustrated by the limitation of what was available to them (note that that approach is great to enforce a styles guide—when there is one). To address this concern we came up with ACSS ( which is a dynamic library that allows authors to use pretty much any style they want, and that includes the use of media queries, combinators, pseudo-classes, etc. Bonus #1: the tool writes/deletes CSS on the fly—which produces even less bloat than a “static” library. The Yahoo! sites that completely switched to Atomizer use less than half of the CSS they use to rely on. Bonus #2: it helps code reviews too! Feel free to join the Gitter channel if you have any question. Lee Kowalkowski said already everything important. I have no idea why the approach of separated concerns is so unpopular. It works completely fine on small and big sites. If you want to work with utility classes, than use a preprocesser, like I mentioned before. Please stop bloating the web with presentational markup, libraries and frameworks, just because you are used to it. It does not make your work faster. I would so much like all you „I-do-it-how-it-most-convenient-for-me“- guys to live in Germany, like I do, where you have to pay 60,- $ for 6 gbyte, when you use your cellphone. Unless you don’t want to pay my telephone bill and share my slow loading web please stop this I do what’s best for me developing behavior. Thank you very much! @ Marc Haunschild The issue is not that Separation of Concern (SoC) is unpopular, it is the fact that some people cannot accept the idea that many devs out there are doing well without following the SoC to the “T”. People in favor of Atomic CSS do not say everybody should switch to it, they only share their experience saying it works well for them. To the contrary, people who “worship” the SoC can’t stop criticising Atomic CSS, without even really knowing what it is about or what it can do. For example, Lee Kowalkowski says: I guess he never realized that Atomic CSS classes could be partner-color, partner-background-color, partner-fontSize, partner-whatever? Such approach solves the “challenge” Lee describes (not changing the HTML). In any case, Atomic CSS proponents do not say using semantic classes is a sin; they also rely on the SoC principle whenever it makes more sense. The idea is to use the best tool for the job. I think it’s better to understand both approaches and make an educated choice rather than sticking to the SoC principle and calling everything else bullshit. Bloating the web (markup?)? Do you have data about this? Because I do, and it’s simply not true (depending on the library). Not only that but you have higher string repetition following a Atomic CSS approach than a SoC approach (since the former promotes a lot of redundancy) which leads to a much better compression ratio. Most importantly, since there is less CSS to download, web sites load faster which translates into a better user experience. This argument is baseless. Yahoo! switched to Atomic CSS and save 55% of its CSS. I don’t know how people can ignore the benefits of Atomic CSS with bandwidth gains of this magnitude. Anyways, if you like the SoC principle and it’s the best way to go for you then that’s great, use that and only that, but please don’t tell devs who use Atomic CSS they don’t know what they are doing, because all it shows is how little you know about the methodology. I just don’t understand, how to answer here, so sorry for any inconvenience, @Thierry Koblentz, I just copy your answer to my post in here: You are aware, that he was writing this, because in the post before @Vanderson said, that theming is only efficient, when using presentational markup. He just answered, that presentational markup is not necessary for this. But I think Lee can clear this up by himself, he doesn’t need me for this. That is exactly, what I meant, when I asked to stop bloating the web. Especially when working with micro data you actually have more hooks for your css than ever necessary. So go ahead: use them! And we can stop the discussion right here ;-) As I and obviously Lee understand HTML5, SoC always makes sense. More than this. SoC gives sense or let’s say meaning to plain text documents. Again in other words (taken from the wcag): Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A) From which point of view? Accessibility? User experience? Or developer experience? You really want to tell me, that minimized, compressed, cachable CSS files are a bigger problem, than dozens of partner-xxx classes added to meaningful HTML5 documents? I’m afraid, I won’t stop telling that it’s a developers responsibility to deliver HTML5 documents, that fit the needs of every user. I know, that it is possible to make accessible websites with bootstrap (to name a framework I had to use before). But I rarely see accessible bootstrap sites. Earlier I just suspected, that developers that use systems like atomic css just want to make their work easier. Today I know it. At least that’s true for the vast majority… And I already said it twice in this thread: go ahead using your beloved naming conventions. But use a preprocessor to get the best of both worlds. See, I’m not telling you to stop doing it. I just ask you to do it right… It doesn’t matter to me how people do their development if they just want to get a job done, they could use Wix for all I care. The fact that sub-standard approaches exist and people find they can make them work is not the issue, the issue is that such approaches have serious problems as already explained, fail to deliver on their promises as I will explain later, and yet they still get airtime on sites like CSS-Tricks, which people rely on to better their knowledge and skills, and trust such resources are a reliable source of authority. Evidently, that bothers me a lot. That hardly solves it. Tomorrow, a new partner brand may require some new properties like a border, and I would need to change the HTML. Unless I add a partner-class for every CSS property in existence, just in case, so no thanks. You mean sampling 4 other sites and publishing this – ? Is that how HTML bloat is measured? On the average class attribute length? I think that’s a little too conveniently biased. Perhaps a different view on the HTML bloat a CSS convention causes is the total number of characters in all class attributes as a percentage of the total number of characters in all opening tags. I think this is more indicative of HTML authoring effort. I wrote a very crude script to measure this: And produced some new data (since old is bad, apparently): Mavo.io (7.4%) CSS Zen Garden (9.4%) Codepen.io (9.8%) Google (10.1%) Wikipedia (10.1%) Wordpress (10.8%) Facebook (11.1%) The Paciello Group (11.3%) CSS-Tricks (13.4%) Ebay (13.8%) Zeldmann (14.1%) W3C (14.4%) Amazon (16.4%) GitHub (18.9%) The Guardian (21.6%) Stackoverflow (16.5%) BBC (27.8%) TED (35.5%) Yahoo (36.3%) Twitter (36.4%) ACSS.IO (42.3%) USA Today (43.2%) Those percentage are the amount of characters the HTML author is spending on class attribute values, when writing any HTML opening tag. I.e. the amount of bloat in the HTML as a result of the approach to CSS. […] Most importantly, since there is less CSS to download, web sites load faster which translates into a better user experience. If you’re measuring website load speed on the thing that gets downloaded on the users very first visit only, you have it backwards. The CSS is cached by the browser, but now every HTML page is bigger, the rest of the experience is slower. CSS bandwidth gains are negated if you make every HTML document consume more bandwidth as a result. When Yahoo’s users wade through their emails or whatever most Yahoo users do, that traffic is additional HTML and ideally zero additional CSS. So, use Atomic CSS for worse user experience? That’s rather rude actually. People should consider everything that experienced people think. None of my objections are baseless, otherwise you wouldn’t have skipped them and instead focused on irrelevancies such as the difference between a theorem and sound advice. @Lee Kowalkowski I said I’d not reply to your future comments but I cannot resist pointing out how “inappropriate” your HTML is: There is no actionable button, the event is attached to the label. So yes, that is inappropriate HTML because that creates a bad user experience (users don’t know what to do after pasting their code in the textarea). Most importantly it is not accessible to keyboard users. Anyway—contrary to what you say and try to demonstrate with your script—the “bloat” related to classes is limited to characters inside class attributes. Everything else is irrelevant because not related to the method being discussed in this article. For example, for this snippet: your script returns: Total size: 42 Open tags: 38chars (90.5%) Class values: 7chars (18.4%) but for this one: we get: Total size: 23 Open tags: 19chars (82.6%) Class values: 7chars (36.8%) Do you see the problem here? Your script suggests that the “Atomic CSS” method ( .a, .b, .c, .d) creates twicest bloat than a “semantic” approach ( .feature) even though in both cases the classattribute contains the exact same number of characters (including whitespace). Yes, new data is better than old data, but only if the former is accurate. PS: Using a component approach it is as easy to add a “partner” class in your component as editing a styles sheet. Actually, the former will not invalidate the user cache as there is a good chance it won’t force you to publish a new CSS file, so there is that too. TTFB (Time To First Byte) is critical. People may not visit your “other” pages if they don’t even wait for your landing page to load). There is no such things are “reloading other pages” on Yahoo!, that’s not how things work. It’s a fiddle, I already confessed it was crude. It was for me, I just thought I’d share my method. A button is a good idea! I did already think that having one would be easier to use, but I was too late, because I had already shared it. Since JS Fiddle versions its URLs, there was nothing I could do, except contemplate how even more websites seem to make my life difficult! It’s attached to the textarea. It would not work if it was attached to the label. The textareaevent would continue to work with or without a button. The button is good for usability, even if it literally does nothing. I have a nasty habit of only doing the bare minimum. Good, at least we agree that inappropriate HTML is bad, happy to illustrate. I may have published it before it was perfect, we pretend that’s acceptable these days. Fortunately for us there are no high-profile articles linking to it and singing its praise. I’m a keyboard user, and it works, just tab out of the textarea. I hope we’re going to discuss something that’s truthful soon, or relevant. I think this is somewhat shortsighted. That’s not bloat, that’s something else, I don’t even know what that is. Bloat is how much additional markup is there in total. Using CSS to its full potential, you can use classes sparingly in your HTML. CSS avoidance schemes unfortunately use classes liberally, this is bloat. Regardless of whether either measurement is perfect (neither are, I admit), the trend in my results still showed that websites with over-engineered approaches to styling had a bigger proportion of class attribute values in the HTML markup. Websites that use classes sparingly have less bloat than those that use them as if they’re going out of fashion (wishful thinking). It’s that simple. My method for measuring bloat penalises liberal use of classes, irrespective of what other HTML is present. I thought that would be a better measure. If you rewrite the same HTML to use a different approach to styling, the difference in measurement would show the difference in bloat better than averaging class attributes, which does not show anything meaningful. Unfortunately I don’t have time to rewrite other people’s bad HTML, or ruin my own, so I just went for a good spread of websites until I got bored, frankly. Your method ignores using classes liberally, so it does not measure bloat at all. In fact, I’m not sure what it proves. It certainly does not address the question of shifting bloat from CSS to the HTML in the FAQ. It’s being overlooked in the article, that’s the benefit of the comment section, where things that are overlooked can be discussed. It’s one of the virtues of using sites like CSS-Tricks, there’s often more to learn from the comments, other points to consider, and maybe receive a balanced view. Yes, that’s called latency, and not influenced by the approach to CSS at all. Nor was it being debated unless I’m mistaken. I can imagine there may exist other ways to get HTML half-full of class attributes into a web page without fetching it all from a server, but that sounds like a lot of effort just to fix something that probably wasn’t an issue in the first place. Most web developers are not Yahoo developers or working on anything so needlessly complex. Even if it is possible to work around the side effects of bloated HTML, the technique would be out of reach of your average web developer. However, your average web developers have a nasty habit of copying what they see, without appreciating whether or not it actually does what they want. So… keep things simple, but no simpler. :) Utility classes are so popular, because it is easy to work with them without using this big grey mass between your ears. I agree, that there is not the one and only perfect System. Of course sometimes it looks ridiculous, when People Show Code like this from ryanair. But if you want the facebook button to get back its border-radius, the laughing will stop. In this Code I see, that there must be an border-radius as a generally design idea. And there are exceptions of this idea. I think the design concept could be not completeley thought through, if so many exceptions are needed. So the Problem is maybe not the CSS concept. With Things like this it is always difficult to deal with. And it will mess up any Code and its concept, if you get a lot of exceptions while already coding. Looking at the ryanair-code, I think a lot of the Things, from which you remove the border, could Need a HTML-class. All social media Buttons for example. So Things would get much easier. I is unlikely, that a designer wants to remove the border-radius from only one social media button, right? And it makes sense in meaningful way to Group These Buttons. If you Need Utility classes I highly recommend to put them in your pre-processor for keeping the HTML clean. Like so: I saw this idea for the first time in a Video by Gunnar Bittersmann: For me it is the best way to literally Combine the best of both worlds: clean, meaningful HTML and readable, reusable CSS/SASS – as a matter of fact I do not Need preprocessors for anything else since we have css classes and grid and Flex.. Marc Sorry for the mistakes – my german autocorrect made it somehow unpleasant to write this english comment :-O Like every other “framework”, “library”, “utility” it will always be subjective. While a lot of sites/frameworks use this is because of the “rapid” ability to create a site. The other thing it does is make every site look pretty much the same. Systems like Bootstrap and Tachyons are great for prototyping but I think for custom websites it’s not a great idea. The main reason is because most are very opinionated and force you to conform to their styles or overwrite them which can be a painstaking process leading to code bloat, specificity issues, etc. For instance with component based you make a change in the stylesheet and it updates the component everywhere. If you’re a “beginner” or not using any sort of build system and you want to change an element that is in multiple places you’ll have to change the class in multiple places. Not maintainable IMHO for larger sites. At the end of the day it’s about who can go to market first with the idea with the most cost-savings which is why these things exist. It’s all short term and not really any thought about long term solutions, which I get because web changes so much, but you can be on the line and go either way if you need to. Of course this is just all an opinion. Because much CSS is autogenerated, along with “html pages”, I’m not sure readability (by humans) is really necessary. Losing the assumption that style declarations must be readable might help spur new thinking.
https://css-tricks.com/growing-popularity-atomic-css/
CC-MAIN-2022-21
refinedweb
13,991
70.53
We will be creating a cascading dropdown list in Blazor using Entity Framework Core database first approach with the help of Visual Studio 2017 and SQL Server 2014. Introduction In this article, we are going to create a cascading dropdown list in Blazor using Entity Framework Core database first approach. We will create two dropdown lists – Country and City. On selecting the value from country dropdown, we will change the value of City dropdown. We will be using Visual Studio 2017 and SQL Server 2014. Take a look at the final application. Prerequisites Creating Tables We will be using two tables to store our data. Create Blazor Web Application Open Visual Studio and select File >> New >> Project. After selecting the project, a "New Project" dialog will open. Select .NET Core inside Visual C# menu from the left panel. Then, select “ASP.NET Core Web Application” from available project types. Put the name of the project as BlazorDDL and press OK. You can observe that we have three project files created inside this solution. Scaffolding the Model to the Application Creating Data Access Layer for the Application Right-click on BlazorDDL.Server project and then select Add >> New Folder and name the folder as DataAccess. We will be adding our class to handle database related operations inside this folder only. Right click on DataAccess folder and select Add >> Class. Name your class DataAccessLayer.cs. This class will handle our database related operations. Open DataAccessLayer.cs and put the following code into it. Here we have defined two methods Adding the web API Controller to the Application This will create our API CountriesController class. We will call the methods of DataAccessLayer class to fetch data and pass on the data to the client side. At this point of time, our BlazorDDL.Server project has the following structure. Adding Razor View to the Application This will add a CountryData.cshtmlpage to our BlazorDDL.Client/Pages folder. Let’s understand this code. On the top, we have included BlazorDDL.Shared.Models namespace so that we can use our Country and Cities model class in this page. We are defining the route of this page using @page directive. So, in this application, if we append “/country” to base URL then we will be redirected to this page. We are also injecting HttpClient service to enable web API call. Similarly, we have another dropdown list to display city data corresponding to each country. On the onchange event of Cities dropdown, we are setting the value of cityName property to the selected city. We are also displaying the selected country name and city name value on the webpage. The @functions section has all our properties and methods. We have defined two variables – countryList of type Country and cityList of type City to handle the countries and cities data respectively. We have also declared three properties to handle countryId, countryName, and cityName data. Hence, we have completed our cascading dropdown list application. Execution Demo Launch the application. Conclusion View All
https://www.c-sharpcorner.com/article/cascading-dropdownlist-in-blazor-using-ef-core/
CC-MAIN-2020-24
refinedweb
502
59.6
A few questions on Stack Overflow have suggested to me that there might be some bits missing from LINQ to Objects. There’s the idea of a “zip” operator, which pairs up two sequences, for instance. Or the ability to apply the set operators with projections, e.g. DistinctBy, IntersectBy etc (mirroring OrderBy). They’re easy to implement, but it would be nice to get a list of what people would like to see. So, what’s missing? 23 thoughts on “What other Enumerable extension methods would you like to see?” It’s not a part of LINQ to Objects, but I’ve always missed a method in Enumerable to just make an IEnumerable with one object. Sometimes you want to Concat a chain of items together and one or several of the steps just consist of a single item; today you have to construct an array or a list with an initializer and pass that, which distracts a bit and makes you figure out the most optimal choice (array). I guess you could use Enumerable.Repeat(obj, 1), but that reads badly. And I guess the problem could be solved by just adding the overload Enumerable.Concat(params T[] items) which would have the compiler and JIT do a passable encapsulation for you. Dynamic Order By: MinOrDefault([optional T item]) .. a wrapper for enumerable.DefaultIfEmpty().Min(). MaxOrDefault(…) .. same. IndexOf(T item) .. the opposite of ElementAt(). Do(Action) or ForEach(Action) perhaps? Zip would, of course, be very useful, but would probably require a standard Tuple class in the framework; we’ve also already implemented our own DistinctBy extension method. Other methods we’ve implemented in our standard utility library are: Any (that returns bool, and has an out parameter that returns the item that matched the predicate) IEnumerable Append(IEnumerable items, T item); Prepend ForEach(IEnumerable, Action) Max & Min (with custom comparers) HashSet ToSet(IEnumerable) We’ve also created extension methods on IList, such as AsReadOnly, CopyTo, FindIndex, etc. public static IEnumerable Concat(this T obj, IEnumerable tail) { yield return obj; foreach (var tailObj in tail) yield return tailObj; } // Matches “First”, but alternatively called “Head” and “Tail”. public static IEnumerable Rest(this IEnumerable enumerable) { using (var enumerator = enumerable.GetEnumerator()) { if (enumerator.MoveNext()) while (enumerator.MoveNext()) yield return enumerator.Current; } } ForEach() like in List I’m not sure all these extension methods need to be standard (don’t want to pollute the namespace too much), but I’d greatly appreciate a means to filter IEnumerable which is order-aware: I want to process it like a stream of elements. I frequently want to split a list in a specific spot after seeing a specific element (or sequence of elements). Or, I don’t want a mere where clause filter, I want to split the stream: basically an elementwise switch statement. Doing this in LINQ now means repeating the same query several times using a different where clause for each switch case (slow). The alternative isn’t attractive either, since a custom implementation will need to fight LINQ’s pull semantics: if you split an Enumerable, and then iterate over one branch, you’ll need to decide what to do with the other branch – cache it? discard and rerun? Going into an even more speculative realm, a hypothetical LINQ for true element streams would be even fancier if they supported a regular expression kind of syntax backed by an NFA/DFA, for simple yet efficient expression of trivial context-dependent processing. @Eamon – have you looked at Push LINQ (MiscUtil)? It would seem to do most of what you want. @Bradley – your Min/Max are already in MiscUtil (EnumerableExt) @Brandon – isn’t Rest the same as .Skip(1)? @Jon – another one from SO: perhaps an AddRange(this ICollection x, IEnumerable y) @John S – Actually easier than that SO answer makes it look. Would be trivial to add to MiscUtil (which I suspect is what Jon intends…). My favorite missing function is Iterate public class Pair { public int Index; public T Value; public Pair(int i, T v) { Index = i; Value = v; } } static IEnumerable<Pair> Iterate(this IEnumerable source) { int index = 0; foreach (var cur in source) { yield return new Pair(index, cur); index++; } } JaredPar: There’s an overload of Select() that already does that. I don’t know the right name for these overloaded extensions, but I’d love to see something like: IEnumerable Slice(this IEnumerable seq, Func) { } IEnumerable Slice(this IEnumerable seq, Func) { } etc… There are hot discussions about why .NET 3.5 doesn’t have ForEach in class Enumerable. Even though there are several reasons/excuses stated 1) List.ForEach always shade extension method; 2) Enumerable methods should be chainable I still would like to have ForEach in Enumerable. @Morgan – re point 2, it still could be… public static IEnumerable ForEach(this IEnumerable source, Action action) { foreach (T t in source) { action(t); yield return t; } } Not sure if it is a great idea, but as a fluent API it seems fine (and still respects read-once streams without buffering). (except of course you’d have to remember to terminate it! damned lazy execution… ;-p) Given that ForEach() would do precisely the same as plain foreach, why would it be needed? @Marc: Having implemented a chained foreach, I don’t think it’s a good idea. It leads to some very un-obvious behavior that’s difficult to debug. In any event, of course, foreach is in the Parallel Extensions. At least, for parallelizeable applications of foreach (and if they’re not, perhaps you should consider refactoring them). @Jacob: I seem to recall seeing an ArraySlice internal to WPF. I could be wrong. But I think I’d rather see that than a direct enumeration. Further, since slices preclude indexes, I’d strongly suggest favoring IList rather than IEnumerable in this case. class Slice: IList { public Slice( IEnumerable source, int startIndex, int maxItems) { … } List cache; // implementation of IList doesn’t bother enumerating until it needs to, then only enumerates as far as the highest index it needs. // In the case of an IList as input, it can do direct indexing rather than enumeration. } What I would like to see? Converters between streams, event sequences, and enumerables. I’ve written them to handle serial ports protocols, and they’re not fun. class StreamSource { Stream Input; Action Aggregator; event EventHandler Output; } class EventSource: IEnumerable { Func projector; // listens to one or more EventHandler, // and buffers a projection // of the event args } Some “experimental” extension methods: (links to automatic translation from Google, sorry, original is in czech language, but code is self-explanatory, I hope). Casting generic collections (workarounds not needed in C# 4.0) Hack for anonymous type Emulation of Bind1St, Bind2nd in C++, “adapters” Not, And, ToPredicate etc. I’ve been trying to code some F# in C#, and ended up rolling the following ‘missing’ links: MapI, FoldI. A while ago I was also surprised not to find ForEach in IEnumerable, but having rolled my own, I was even more surprised when nothing happened! Having thought further, I decided on two extension methods: public static void Iter(this IEnumerable input, Action action) { input.ToList().ForEach(action); } (I consider this to be justified, on the basis of Seq.iter) And this ‘pass-through’ extension (which I’m slightly less easy with, I first thought of calling it ‘Log’, but SideEffects is a better warning): public static IEnumerable SideEffects(this IEnumerable items, Action pPerfomAction) { foreach (T item in items) { pPerfomAction(item); yield return item; } } Then there are these two: I sorely miss the ability to remove certain elements from a collection – I would like to see something like Java’s Iterator.remove() PositionalJoin (see) is interesting. What I’d really like to see though is for specialized collections such as System.Windows.Forms.ControlCollection to be retrofitted with the correct IEnumerable interface so Linq to Objects queries can be used against them without first having to do a Cast(). From my own extensions project on Codeplex – NExtension: Clump – Reverses SelectMany by clumping a flat list into list of lists of a fixed size. AtLeast – Similar to Any, but can check for “at least x” number of items instead of just 1. AtMost – Same as AtLeast, but for All. Checks for “at most x” number of items. These and Zip are probably the most useful. Feel free to use.
https://codeblog.jonskeet.uk/2008/10/23/what-other-enumerable-extension-methods-would-you-like-to-see/?like_comment=10532&_wpnonce=5d8d81fac5
CC-MAIN-2021-21
refinedweb
1,395
53.51
Strong typing–you either love it or hate it! Elaborate type systems catch a lot of programming errors at compile time. On the other hand they impose the burden of type annotation on the programmer, and they sometimes disallow valid programs or force type casting. In Java there’s been a never-ending discussion about the lack of support for const types. People coming from the C++ background see it as a major flaw. Others would defend Java from constness with their own bodies. I’m always on the lookout for solutions that let programmers have a cake and eat it too. Pluggable types are just the thing. You want const enforcement? Add a constness plug to your compiler. You want compile time null reference checks? Add another plug. How is it possible? Java annotations as type modifiers Did you know that Java had a system of user-defined annotations (C# has a similar thing)? Annotations start with the @ sign and can be used, for instance, to annotate classes or variables. The Java compiler doesn’t do much with them other then embed them as metadata in class files. They can be retrieved at runtime as part of the reflection mechanism. I never thought of annotations as more than an ad hoc curiosity until I read Matthew Papi’s Ph.D. thesis, Practical pluggable types for Java. The paper proposes the use annotations to extend the Java type system. This work contributed to the JSR 308 proposal, which allows annotations to appear anywhere types are used. For instance, you could annotate a declaration of an object with the @NonNull qualifier: @NonNull Object nnObj; or declare a read-only list of read-only elements: class UnmodifiableList<T> implements @ReadOnly List<@ReadOnly T> { ... } What distinguishes such annotations from bona fide comments is that they can be type checked by user-defined checkers. These checkers can be plugged into the compiler and run during compilation. They get access to abstract syntax trees (ASTs) produced by the language parser, so they can also do semantic checks (e.g., detect method calls through a potentially null pointer). Examples of type system extensions A simple NonNull checker detects assignments of potentially null objects to non-null objects, as in: Object obj; @NonNull Object nnObj = obj; // warning! The checker must know that the default qualifier is @Nullable (potentially null) and @NonNull is a “subtype” of @Nullable (strinctly speaking, @NonNull T is a subtype of @Nullable T). In fact, simple type annotations of the @Nullable variety may be defined within the program and type-checked by the generic Basic Type Checker provided as part of the type checker framework. For instance, the subtyping relationship may expressed declaratively as: @TypeQualifier @SubtypeOf( { Nullable.class } ) public @interface NonNull { } However, a specialized checker can do more than just check type correctness. The NonNull checker, for instance, issues a warning every time the program tries to dereference a @Nullable object (remember that @Nullable is the default implicit annotation). An even more useful checker enforces immutability constraints (the generalization of const types). The IGJ checker (Immutability Generic Java) introduces, among others, the following annotations: - @Mutable: The default. Allows the object to be modified. - @ReadOnly: An object cannot be modified through this reference. This is analogous to C++ const reference. - @Immutable: An object may not be modified through any reference (not only the current one). Java Strings are immutable. Incidentally, similar immutability constraints are built into the type system of the D programming language, except that D’s const and immutable (formerly known as invariant) are transitive. Try it! Suppose you are a fan of immutability constraints and you want to try them right now. First, download the JSR 308 compiler and checkers from the pluggable types web site. To compile your annotated program, use the command line: javac -processor checkers.IGJ.IGJChecker <source-files> If your program doesn’t obey immutability constraints specified in your source code, you’ll see a bunch of warnings and errors. Now for the annotations. You might want to do them bottom up: - Annotate methods that don’t modify this: void foo() @ReadOnly; These methods may only call other @ReadOnly methods of the same object (the checker will tell you if you break this rule). - Annotate arguments that are not modified by a method, e.g., void foo(@ReadOnly Bar bar); - Annotate objects that never change after creation: @Immutable Bar bar = new @Immutable Bar(); And so on… You can pass @Immutable as well as @Mutable objects to methods that take @ReadOnly arguments, but not the other way around. Of course, any attempt to modify a @ReadOnly or @Immutable object will be flagged as error by the checker. Nullness checker The nullness checker protects your program from dereferencing uninitialized objects. For instance, you can only call a method or access a property of an object that is typed as @NonNull. Since the implicit default annotation is @Nullable, the following code will be flagged as an error: Bar bar; bar.toString(); There are some interesting issues related to nullness. For instance, during object construction, this cannot be considered @NonNull. Consequently you cannot call regular methods from an object’s constructor. To remedy this situation without compromising the type system, a special annotation @Raw was added. Inside the constructor, this (and all @NonNull subobjects under construction) are considered @Raw. So if you want to call an object’s method from inside its constructor, such method must be annotated @Raw. Polymorphism It’s possible to overload functions based on their nullness annotation. For instance, if you know that a function’s argument is @NonNull, you might want to skip a null test: String stringize(Bar bar) { if (bar != null) return bar.toString(); else return ""; } // Specialized version String stringize(@NonNull Bar bar) { return bar.toString(); } Interestingly, since the compiler does flow analysis, it knows that inside the if statement bar is not null, even though it’s (implicitly) declared as @Nullable, so it won’t flag it as an error. (This is called flow-dependent typing–I implemented something like that in my Dr. Dobb’s article using local variable shadowing.) Let’s try something more challenging–declaring the identity function, a function that simply returns its argument. The naive declaration T identity(T x); has a problem when nullability annotations are in force. Since the default annotation is @Nullable, the above is equivalent to @Nullable T identity(@Nullable T x); When called with a @NonNull argument, this function will return a @Nullable result. That’s not good! You can ameliorate this situation by declaring a separate overload: @NonNull T identity(@NonNull T x); The problem is that, when you keep adding new kinds of type annotations to your system, the number of overloads of identity starts growing exponentially. Enter polymorphic annotation @PolyNull. The identity function can pass the nullness annotation through, if you declare it as follows: @PolyNull T identity(@PolyNull T x); Amazingly enough, @PolyNull will also work with multiple arguments. Consider the max function: @PolyNull T max(@PolyNull T x, @PolyNull T y); Through the magic of type unification, this declaration does the right thing. The nullability annotations of both arguments are unified to the lowest common denominator–the most derived annotation in the subtyping hierarchy to which both types can be implicitly converted. So, if both arguments are @NonNull, their unification is @NonNull, and the result is @NonNull. But if even one of the arguments is @Nullable, then the result is @Nullable. Notice that this declaration covers four possible overloads: @NonNull T max(@NonNull T x, @NonNull T y); @NullableT max(@NonNull T x, @NullableT y); @NullableT max(@NullableT x, @NonNull T y); @Nullable T max(@NullableT x, @NullableT y); For non-static methods, the annotation of this may also take part in the unification: @PolyNull T foo(@PolyNull T x) @PolyNull; Shortcomings One of the limitation of user-defined type annotations is that they can’t take part in program optimization. That’s because the type checker is not allowed to modify the AST. (See Walter Bright’s blog in Dr. Dobbs about optimization opportunities based on immutability in the D programming language.) Acknowledgments Michael Ernst, who was Matthew Papi’s doctoral adviser, clarified some of the issues for me. Since I’m attending his seminar, I’ll be blogging more about his work. January 18, 2009 at 6:22 pm “Elaborate type systems catch a lot of programming errors at compile time. On the other hand they impose the burden of type annotation on the programmer, and they sometimes disallow valid programs or force type casting.” You’re not talking about elaborate type systems there. You’re talking about pathetic and impractical type systems like Java’s. An elaborate type system most certainly does not burden you with type annotations and disallows far fewer valid programs than Java’s type system does. Further, an elaborate type system disallows type casting altogether. I hope this helps. January 19, 2009 at 4:53 am You wrote: “On the other hand they impose the burden of type annotation on the programmer, and they sometimes disallow valid programs or force type casting.” My opinion: 1. A burden of type annotation? I don’t understand. If you are e.g. declaring a function which is to be called from other modules, you have to state the types of its parameters – otherwise you might end up calling the function with arguments it cannot process. This is a burden? On the other hand if you mean [unnecessary type “annotations” in the body of a method in Java], then you are right – but the fact that Java requires each declaration of a variable to have an explicit type, does not imply that it is the programmer who has to fill it in. If the type of a variable can be inferred from its initial value, why does not the IDE automatically fill it in? (Hint: Because the IDE has been implemented by the same organization which designed the Java language?) 2. How can a consistent type-system disallow valid programs? Such an idea is completely insane. Unless you are talking about crappy type-systems only. 3. Sometimes forces type casting? Just because many popular programming languages do/allow type casting in a similar way to C/C++ or Java, it does not imply that it is the best way to do it. Contrary to the previous comment, I do not believe our opinions will help you in any way because you are simply unable to understand them. January 19, 2009 at 6:33 am 1. “If you are e.g. declaring a function which is to be called from other modules, you have to state the types of its parameters – otherwise you might end up calling the function with arguments it cannot process.” This is absolute nonsense. Haskell — QED 2. How can a consistent type-system disallow valid programs? It’s known law of theoretical computer science. Have fun figuring it out 🙂 January 19, 2009 at 6:44 am This is a nice, informative article; I don’t understand the vitriol behind the comments. I was unaware the term “elaborate type system” was clearly and categorically defined. Elaborate seems like a somewhat meaningless adjective in this usage, kind of like saying “cool type system” or “better type system”. These are undefined value judgements and IMO worthy of an informed comment rather than condemnation. A few of my comments: “If you are e.g. declaring a function which is to be called from other modules, you have to state the types of its parameters”. This hasn’t been the case with my experience. Type inference systems like HM used by F# and OCaml don’t force you to declare types on functions. The compiler can infer them for you. I don’t think your comment is accurate for this reason. “How can a consistent type-system disallow valid programs?” Although I have not programmed in Haskell, I do know from experience that type system constraints in F#/OCaml sometimes require you to annotate your program with metadata in order to compile. For instance, I can write a correct string manipulation function but in some cases the type inference engine sees ambiguity in the types and I need to add annotations. I see this as a programming language type system disallowing a valid programming. Perhaps you’re thinking of something different. I am unaware of a true, correct, one-type-system-to-rule-them-all. It seems like type systems are always a tradeoff between competing concerns… and designing a programming language is much the same. I’m not sure speaking in absolutes is helping me understand your comment. Some more examples of of your statements would be helpful. January 19, 2009 at 7:42 am “This is absolute nonsense. Haskell — QED”. May I ask you to do a favor? Translate this piece of pseudo-code into Haskell for me: module 1 (implementation ‘impl1’): int fn(int x) { return (x*x) } int restricted-fn(restricted_int x) { return fn(x) } module 1 (declaration): type restricted_int(x) = ((x is int) and (abs(x)<10)) function fn(int x) returns int function restricted-fn(restricted_int x) returns int module 2 (implementation): import declarations from module 1 do { restricted-fn(1) restricted-fn(20) } application 1: load module 1, use implementation impl1 execute module 2 January 19, 2009 at 7:59 am 2. How can a consistent type-system disallow valid programs? It’s known law of theoretical computer science. Have fun figuring it out 🙂 — G.E.B. – Yes, it’s fun. — I meant something like this: [unable to compile a program because it fails type checking (for whatever reason)] is equivalent to saying that [you have been unable to prove at least that part of the validity of the program which is enforced by the type system]. — If a program is indeed valid (= checked by a man) but it fails to compile (by a machine) in programming language X, then the type-system has to be extended to accommodate for this program. In other words, an “elaborate” type-system has to be extensible. January 19, 2009 at 8:26 am Hamlet D’Arcy wrote: “For instance, I can write a correct string manipulation function but in some cases the type inference engine sees ambiguity in the types and I need to add annotations. I see this as a programming language type system disallowing a valid programming.” In order for me to understand what you are saying I need to resolve the following question: 1. Is that some form of type-casting in the sense “int x = fn(); struct S *y = (struct S*)x;” as in C/C++, 2. or are you just helping the type-checker to finish a proof it cannot figure by itself? If it is the latter, then I wouldn’t call it “type system disallowing a valid programming”. Some people may interpret it as “the type system is enabling valid programming”, or they may call it “a future-proof type system”, or “a form of an extensible type system”. January 23, 2009 at 1:22 am 1. Type inference. 2. Can you have a List of @Nullable Strings? January 23, 2009 at 2:52 am 1. Whole program analysis? Think of a library function returning an object. Is the object @Nullable or @NonNull? You can’t tell unless you look into the implementation. 2. Strings are reference types, so @Nullable is the default. String s = null is valid. January 23, 2009 at 5:32 am @anonymous – the annotation is you helping the compiler figure out the type, not performing a conversion. @Ricky – Yes you can have a list of @Nullable Strings. @Bartosz – There is a mechanism to apply a “Nullable Configuration” file to a foreign API, marking externally the Nullability of methods. So to create the file you do need to look in the implementation, but once created you can easily integrate 3rd party libraries that don’t use the annotations into yours which does. It seems like some of the anonymous posts are trolls. January 23, 2009 at 11:42 am Ricky’s comment was very terse, so I assumed that he meant pure type inference, without any annotations. If you allow partial annotations, you may run a special tool over your code that will infer the remaining types. Of course, it will do it conservatively. February 4, 2009 at 2:53 pm In my humble opinion, the Annotations just add unnecessary complexity to the language. The elegance and simplicity that was Java originally, is slowly fading away. I am willing to put up with Templating (arrived in Java 1.5 from C++ and others), as it is very valuable to actually helping with type safety and ultimately simplifying the code. But Annotations are really there for the nasty and ugly thing that is Code Generators (like EJB Compilers, etc.). The end result is that it’s becoming increasingly more complex to even compile Java. Since you need to put together Annotations add-ons and further put together EJB compilers, etc. About @NonNull — declaring something as “NonNull” is only going to force developer who is about to activate “non-null” either extra checking for null (which is usually unnecessary) or do some worse perversion, not resulting in anything good. If you are coding: String someStr; someStr.find(“something”); Then most modern editors (Eclipse, etc) will immediately alert you to your silliness. No Annotations needed… February 4, 2009 at 7:30 pm The beauty of annotations is that they are optional. In fact, even in D, the use of const or immutable in the client program is mostly optional. A non-annotated program will compile just fine. There are some clients who are very interested in using NonNull for better reliability. Wall Street firms were among them (maybe not any more 😉 February 5, 2009 at 6:38 pm I guess I just think that: NonNull != Reliability But it’s one of those formulas that is really hard to prove 🙂 February 5, 2009 at 6:58 pm Well, don’t you think that Eclipse flagging null dereference increases the reliability of your programs? NonNull serves the same purpose but can cover more cases because it can be propagated across method call boundaries. February 5, 2009 at 7:16 pm Why not just copy the more advanced languages with decent type systems? February 5, 2009 at 7:29 pm If there already is a perfect language then instead of copying it, why not just use it? Unfortunately there is no consensus as to which solutions are the best, so we have to discuss the pros and cons and pick the best fit for a given language. I’m trying not to take sides, just present the options. February 5, 2009 at 7:53 pm There is not a consensus that there is a perfect language, but there is certainly consensus that Java is inferior and impractical in every possible aspect. I don’t use it, unless I’m writing for Functional Java – which exists simply to help make Java somewhat useful in the event that irrational authoritarianism forces me to use it. It is also apparently useful for many others who are in this position – thankfully I am not. I hate knowing Java back-to-front. You see it for what it really is.
https://bartoszmilewski.com/2009/01/18/java-pluggable-types/
CC-MAIN-2017-34
refinedweb
3,225
55.13
. I." I added some functions to make a baby step into Domlette parsing. I call these the brain-dead APIs (though we use more decorous terms officially). You can now get yourself a crisp DOM with as little effort as: >>> from Ft.Xml import Parse >>> doc = Parse("<hello>world</hello>") And thence on to the usual fun stuff: >>> print doc.xpath(u"string(hello)") world Parse also knows how to handle streams (file-like objects): >>> doc = Parse(open("hello.xml")) Do a help(Parse) to get a warning about using that function with XML that is not self-contained, and an example of how to parse such XML properly in 4Suite. There is also ParsePath, which handles files paths and URLs: >>> from Ft.Xml import ParsePath >>> doc = ParsePath("hello.xml") >>> doc = ParsePath("") And what do you know? That last URL does not parse. My feed is ill-formed. ☠☠☠☠☠ (I love cursing in Unicode) Sigh. Gotta fix the PyBlosxom Atom generation. Maybe we need a touch of 4Suite (Amara, actually) there, as: ...in nearly all cases I find the 'wizard approach' is great to get you started, but then very quickly gets complex again. Anyone who uses Microsoft's Visual Studio, for example, will know that getting a C++ application up and running quickly, with support for multiple windows, toolbars, printing and file saving, is a snip. But then when you want to modify that code and move away from the wizard, you are very soon into normal C++ territory.. Well,'] "Thinking. I tried to post this to the Markdown mailing list, but they have a policy of rejecting (not just moderating) non-member mailings. Seems a bit harsh to me, considering that a combination of moderation and spam filtering is not really that much of a burden (as I know from copious experience), but whatevah. I really don't have room to join yet another mailing list. In response to a thread that started out discussing internal links, and then falling back to footnotes, Arisotle Pagaltzis made this brilliant suggestion:"> I want to say to the Markdown folks: please, please listen to Aristotle's suggestion. It is exactly what Markdown needs now. It would add much of the power and flexibility that is currently lacking when I consider Markdown against reStructuredText, and it would do so without the welter of punctuation in ReST. A complete win. He also gives an example of how this would enable useful image elements for Markdown: {@align=center} Currently it is not possible to use Markdown syntax to produce images that meet general usability guidelines. You have to embed a full img tag. Aristotle's suggestion elegantly solves that problem as well. I think that this is far more important than such minutiae as footnotes, which are all the current rage on the Markdown list. This is not to say that the need for footnotes is minute, but rather that the need for footnotes can easily be seen as one aspect of a more general problem in expression. If Markdown had a way of asserting ID attributes, there would be flexible support for the many different ways people want to express footnotes, margin notes, biblio refs, etc. But by solving footnotes as a complete problem in themselves, Markdown is just heading down the path to punctuation madness. I suggest starting with flexible attribute syntax such as Aristotle suggests, using this for footnotes as far as it goes, and then, if usage experience shows that something yet more convenient is needed, reconsider specialized footnote syntax. I also think it's worth explicitly supporting the attribute syntax at the top of a markdown document as a way to express overall document metadata, which is another gap I see in Markdown. In his concurrence Jelks Cabaniss suggests: The only thing I might add are "shortcuts" when the attributes are ID and CLASS: {#foo}as an alias of {@id=foo}, and {.bar}for {@class=bar}. But I think these should be left off for the moment, and maybe added later if they seem especially useful. Again I'm just wary of increasing the amount of punctuation one has to remember. Jelks does wrap up with what I consider the knockout point: BTW, take a look at. It's sprinkled full of "real HTML" precisely because of this deficiency. (There aren't any CLASS attributes in that particular document, but even there, if there were Markdownish equivalents of ID and TITLE attributes, that would all go away.) I'm pretty sure I'll implement this into my Python Markdown tools even if it doesn't become part of the "official" Markdown spec. I need it too badly (I really don't want to have to move to ReST just yet). For a while 4Suite has had an 80/20 DOM implementation completely in C: Domlette (formerly named cDomlette). Jeremy has been making a lot of performance tweaks to the C code, and current CVS is already 3-4 times faster than Domlette in 4Suite 1.0a4. In addition, Jeremy stealthily introduced a new feature to 4Suite, Saxlette. Saxlette uses the same Expat C code Domlette uses, but exposes it as SAX. So we get SAX implemented completely in C. It follows the Python/SAX API normally, so for example the following code uses Saxlette to count the elements: from xml import sax furi = "file:ot.xml" class element_counter(sax.ContentHandler): def startDocument(self): self.ecount = 0 def startElementNS(self, name, qname, attribs): self.ecount += 1 parser = sax.make_parser(['Ft.Xml.Sax']) handler = element_counter() parser.setContentHandler(handler) parser.parse(furi) print "Elements counted:", handler.ecount If you don't care about PySax compatibility, you can use the more specialized API, which involves the following lines in place of the equivalents above: from Ft.Xml import Sax ... class element_counter(): .... parser = Sax.CreateParser() The code changes needed from the first listing above to regular PySax are minimal. As Jeremy puts it: Unlike the distributed PySax drivers, Saxlette follows the SAX2 spec and defaults feature_namespacesto Trueand feature_namespace_prefixesto Falseboth of which are not allowed to be changed (which is exactly what SAX2 says is required). Python/SAX defaults to SAX1 behavior and Saxlette defaults to SAX2 behavior. The following is a PySax example: from xml import sax furi = "file:ot.xml" #Handler has to derive from sax.ContentHandler,' #or, in practice, implement all interfaces class element_counter(sax.ContentHandler): def startDocument(self): self.ecount = 0 #SAX1 startElement by default, rather than SAX2 startElementNS def startElement(self, name, attribs): self.ecount += 1 parser = sax.make_parser() handler = element_counter() parser.setContentHandler(handler) parser.parse(furi) print "Elements counted:", handler.ecount The speed difference is huge. Jeremy did some testing with timeit.py (using more involved test code than the above), and in those limited tests Saxlette showed up as fast as, and in some cases a bit faster than cElementTree and libxml/Python (much, much faster than xml.sax in all cases). Interestingly, Domlette is now within 30%-40% of Saxlette in raw speed, which is impressive considering that it is building a fully functional DOM. As I've said in the past, I'm done with the silly benchmarks game, so someone else will have to pursue matters to further detail if they really can't do without their hot dog eating contests. In another exciting development Saxlette has gained a generator mode using Expat's suspend/resume capability. This means you can have a Saxlette handler yield results from the SAX callbacks. It will allow me, for example, to have Amara's pushdom and pushbind work without threads, eliminating a huge drag on their performance (context switching is basically punishment). I'm working this capability into the code in the Amara 1.2 branch. So far the effects are dramatic.. There.
http://copia.posthaven.com/tag/python?page=9
CC-MAIN-2018-51
refinedweb
1,294
64.1
i m working on firewall on linux platform....could you please send me ypur code for assistance..on prat.wap@gmail.com linux firewall code needed.. urgent! has anyone out there got a complete working code on linux based firewall?? plz help!! complete firewall code for linux... Hi... v r dng a project on firewall for linux... can u please give d code of a simple packet filter firewall for linux... my mail id is ramyavastrad@gmail.com linux firewall hey , we r doing project on a network security.. we r going to build a DMZ for a private network. In which we r supposed to build our own firewall on linux. so could u plz guide us regarding how to start with the project.. we would be very thankful to u if u provide us with the complete soursecode ..my id is rati_flyhigh@rediffmail.com firewall code needed hey friends am planning to do a project on linux firewall.but dont hav any idea on how to do it.so pls if any1 has any info about the logic and got the complete code ,pls do mail it to me at so_thoms@yahoo.co.in pls HELP ME..i want it early Re: Building a Linux firewall i'm building a linux firewall in bash en a configuration file can somebody help me with a complete code so i can have an idea how i can began,my e-mail is mgend_@hotmail.com Re: Building a Linux firewall Can you provide a complete source code My Mail ID : george_s_kalarikal@yahoo.co.uk Re: Building a Linux firewall # cat set_policy.c #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <linux/ip.h> #include <linux/tcp.h> #include <linux/udp.h> #include <linux/ip_fw.h> main(int argc, char **argv) { int p, sfd; struct ip_fw fw; fw.fw_flg = 0; if (strcmp(argv[1], "accept") == 0) { p = IP_FW_F_ACCEPT; } else if (strcmp(argv[1], "reject") == 0) { p = IP_FW_F_ICMPRPL; } else if (strcmp(argv[1], "deny") == 0) { p = 0; } sfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); setsockopt(sfd, IPPROTO_IP, IP_FW_POLICY_FWD, &p, sizeof(int)); } Need a bit help This is Shobhit here....i m trying to build a kind of firewall in C...actually i m looking for specific URL blocking for a bandwidth manager box....i mean to say a program that can recognize the packet information from the network....and that sort them and then block the required packets.....if u ould help me with this....more over if u could send me the full ode than atleast i will get some idea...thanx netfilter Can anyone help me to code a firewall using netfilter which will support multiple rules can you provide me a complete code? hi, i am developing a firewall for my system and i would like to look at you code for that purpose. i would appreciate if u would email me the same at folowing id: guy_from_rolla@yahoo.com thanks! john. need help hi, we have a LAN and a gateway in it. We want to hold all the packets coming into the gateway for compression /modification. we want help for this. thank you. dhaubaji@yahoo.com Give a complete code not just a part of it Would you please give a complete code not a part. My email id:- avi_comp@rediffmail.com Re: Building a Linux firewall Would you please give a complete code not a part. My email id:- avi_comp@rediffmail.com Building a Linux firewall hi there..we are currently working on a firewall for our thesis..i was hoping if anybody can help me.. can you send me the complete source code..here's my email: juno_king2000@yahho.com.. thank you..
http://www.linuxjournal.com/article/1212?quicktabs_1=2
CC-MAIN-2014-42
refinedweb
626
77.74
The other day there was a question about serving static files from episerver, like a robots.txt. Since most editor like to be able to update the robots.txt them self many of us has build solutions for that. There are also some packages in the nuget feed from EPiServer that will help you do just that. But if you are like me, I do not like to have pre-compiled solutions from other companies in my project, some are better then others but still I like to be able to change most of my code in a project. Of course you can download the source code in many of those packages but some times they tend to do a bit more then you might expected as well. In this case I just would like to serve a robots.txt if it is requested by a search engine for instance. First I create the robots.txt controller. Since we are working with EPiServer CMS I have added a textarea on the startpage type and therefore editors are able to change the content of the file. 1: public class RobotsTxtController : Controller 2: { 3: private Injected<IContentLoader> ContentLoader { get; set; } 4: 5: [ContentOutputCache] 6: public ActionResult Index() 7: { 8: var startPage = ContentLoader.Service.Get<StartPage>(ContentReference.StartPage); 9: 10: string content = startPage.RobotsTxtContent; 11: return Content(content, "text/plain"); 12: } 13: } Nesx step is to create an initialization module were we map a route to our robots.txt file. 1: [InitializableModule] 2: [ModuleDependency(typeof(EPiServer.Web.InitializationModule))] 3: public class RenderingInitialization : IInitializableModule 4: { 5: public void Initialize(InitializationEngine context) 6: { 7: 8: //Maps route for robots.txt 9: RouteTable.Routes.MapRoute("RobotsTxtRoute", "robots.txt", new { controller = "RobotsTxt", action = "Index" }); 10: } 11: 12: 13: public void Preload(string[] parameters) { } 14: 15: public void Uninitialize(InitializationEngine context) 16: { 17: //Add uninitialization logic 18: 19: } 20: } And finally we add the property to our startpage model [UIHint(UIHint.Textarea)] [Display(Name = "Robots.txt", Order = 90, GroupName = Global.GroupNames.SiteSettings)] public virtual string RobotsTxtContent { get; set; } Nice idea! Thanks. No offense, just wanted to know reason using Injected ..? :) To Valdis Is it used for querying the pagedata from startpage reference? Thanks Eric, nice & simple => a perfect solution. Happy you like it :)
https://world.episerver.com/blogs/Eric-Pettersson/Dates/2015/4/simple-robots-txt-build-with-asp-net-mvc/
CC-MAIN-2019-39
refinedweb
375
56.96
16 October 2013 17:32 [Source: ICIS news] HOUSTON (ICIS)--Alcoa’s joint-venture aluminium smelter in ?xml:namespace> Alcoa’s integrated Ma’aden-Alcoa smelter project with Saudi Arabian Mining Company (Ma’aden) is in its initial start-up phase. Aluminium smelting is a key market for caustic soda. Alcoa said that the joint venture was working to restore the potline, which should be back online between the first and second quarter of 2014. The ramp-up of the smelter’s second potline was ongoing and would now be accelerated, it added. The incident on the first line is not expected to have any impact on Alcoa’s customers, and there were no impacts on Ma’aden-Alcoa’s mine, refinery or rolling mill, it said. Alcoa formed the joint venture in 2009 to build “the largest and lowest-cost integrated aluminium facility”
http://www.icis.com/Articles/2013/10/16/9715884/Maaden-Alcoa-halts-part-of-production-in-Saudi-smelter-ramp-up.html
CC-MAIN-2015-14
refinedweb
144
53.1
Difference between revisions of "PyANM" Revision as of 21:35, 19 October 2014 Contents Introduction Elastic Network Models (ENM) have been successful in reproducing fluctuations for proteins of native conformations. ENM is a coarse-grained method for modeling protein dynamics, meaning in generally in ENM each residue is represented by one bead in its Alpha Carbon position. These beads are then connected by elastic springs if the distance between two beads fall under a cutoff value (usually within the range of 7 to 15 angstroms). For more details please read here. PyANM is developed as a cross-platform Pymol Plugin to allow its users to build and visualize Anisotropic Network Models, a member of the ENM family. This plugin allows its users to draw arrows or make movies based on calculated mode motions, to draw all springs used to build the ANM within the protein, to color the protein based on its Mean Square Fluctuations (MSF) calculated from ANM and to export data from ANM for future processing. PyANM also allows its users to change the colors and scales (sizes) for movies or arrows generated by PyANM for better visualization. Dependencies - PyANM requires Numerical Python (NumPy) to do all the matrix calculations. If you wish to use PyANM but don't have NumPy on your machine, please follow the download and build instructions here. If you will be using PyANM on a Windows machine, installing a Python distribution such as Anaconda might be the easier. After installing NumPy, type the following line inside Pymol and if you don't see any error messages, you now have NumPy ready for Pymol! import numpy - PyANM has only been tested for Pymol 1.1 and higher, using an earlier version on Pymol might cause problems. Installation Download pyanm.py from this page, then go to Pymol-->Plugin-->Manage Plugins-->Install..., select the file you have just downloaded and then restart Pymol. Things might be different depending on your Pymol version and your local system, but this should be fairly similar. After a successful installation, go to Pymol-->Plugin and you will see PyANM, click on it and you should see PyANM's interface just like in figure 1. Usage Now that you have PyANM installed, let's build one ANM together! Structure Handling - Type the name of your protein structure under 'Select Structure', this could either be a valid 4-letter PDB (Protein Data Bank) ID or the name of a object you have already loaded into Pymol. - You could also choose to upload a local file from your system using the 'Browse' button. - If the check box 'Use only Alpha Carbons' is checked, even if you choose an all-atom structure, PyANM will coarse-grain the structure for you. Otherwise PyANM will build an all-atom ANM if an all-atom structure is used. - If the check box 'Include HETATMs' is checked, PyANM will include atoms in PDB that starts with HETATM as well. ANM Parameters - So far there are two ANMs available in PyANM : the cutoff model as described here and the Parameter Free Model described here, where spring constants are adjusted based on distance between two residues. - If you choose to use Cutoff Model, you will be able to choose your desired cutoff value. The default value is 12 angstroms, personally I would recommend using any value between 7 angstroms to 15 anstroms. - If you choose to use Parameter Free Model, you will be able to choose the power t for calculating spring constants for all residue pairs, where spring constant k for residue i and j is calculated as 1/distance(i,j) to the power of t. The default value for power t is 6. Build ANM Once you have selected the structure you wish to use as well as the model and its parameters, you should be able to build your ANM simply by clicking 'Build ANM'.A window will pop up telling you your ANM was built successfully once the calculation has finished. For a protein with less than 200 residues, this should take less than 10 seconds.. Control Panel This is where PyANM allows you to change the scale (size) of the movies (arrows), or change color of the arrows (The color of movie objects could simply be changed like you change colors for other objects in Pymol). You could either predefine scales (sizes) or colors you would like before building your ANM or you could change these settings after you have made movies or arrows and these changes will happen real-time. You could also select what attributes you would like to export to your local system here inside control panel. These data will be written as text files and Numpy-ready for future processing. Contact Author Thank you for using PyANM, please feel free to contact me at yuanwang (at) iastate (dot) edu about anything, especially if you are having problems with PyANM.
https://pymolwiki.org/index.php?title=PyANM&diff=prev&oldid=11739
CC-MAIN-2020-29
refinedweb
820
58.11
Debugging Swift code with LLDB As engineers we spend almost 70% of our time on debugging. The rest 20% goes on thinking about the architectural approaches + communication with teammates and just 10% actually on writing code. Debugging is like being the detective in a crime movie where you are also the murderer. — Filipe Fortes via Twitter So it’s extremely important to make this 70% of our time as pleasant as possible. LLDB comes to rescue. Fancy Xcode Debugger UI shows you all available information without typing a single LLDB command. However, the console is still a big part of our workflow. Let’s break down some of the most useful LLDB tricks. I personally use them daily for debugging. Where should we go first? LLDB is an enormous tool and it has a lot of useful commands inside. I won’t describe them all. I’d like to walk you through the most useful commands instead. So here is our plan: - Explore variables values: expression, e, po, p - Get overall app’s state + language specific commands: bugreport, frame, language - Control app’s execution flow: process, breakpoint, thread, watchpoint - Honorable mentions: command, platform, gui I have also prepared the map of useful LLDB commands with description and examples. If you need you can hang it above your Mac to remember these commands 🙂 1. Explore variables value and state Commands: expression, e, po, p The basic function of a debugger is to explore and modify variables’ values. This is what expression or e is made for (and much more actually). You can evaluate basically any expression or command in a runtime. Let’s assume you’re debugging some function valueOfLifeWithoutSumOf() which do a summation of two numbers and extract the result from 42. Let’s also assume you keep getting the wrong answer and you don’t know why. So to find a problem you can do something like this: Or… it’s better to use LLDB expression instead to change the value in the runtime. And find out where the problem has happened. First, set a breakpoint to a place you interested in. Then run your app. To print the value of specific variable in LLDB format you should call: (lldb) e <variable> And the very same command is used to evaluate some expression: (lldb) e <expression> (lldb) e sum (Int) $R0 = 6 // You can also use $R0 to refer to this variable in the future (during current debug session)(lldb) e sum = 4 // Change value of sum variable(lldb) e sum (Int) $R2 = 4 // sum variable will be "4" till the end of debugging session expression command also has some flags. To distinct flags and actual expression LLDB uses double-dash notation -- after expression command like this: (lldb) expression <some flags> -- <variable> expression has almost ~30 different flags. And I encourage you to explore them all. Write the command below in the terminal to get full documentation: > lldb > (lldb) help # To explore all available commands > (lldb) help expression # To explore all expressions related sub-commands I’d like to stop on the following expression's flags: -D <count>( --depth <count>) — Set the max recurse depth when dumping aggregate types (default is infinity). -O( --object-description) — Display using a language-specific description API, if possible. -T( --show-types) — Show variable types when dumping values. -f <format>( --format <format>) –– Specify a format to be used for display. -i <boolean>( --ignore-breakpoints <boolean>) — Ignore breakpoint hits while running expressions Let’s say we have some object called logger. This object contains some string and structure as properties. For example, you want to explore first-level properties only. Just use -D flag with appropriate depth level to do so: (lldb) e -D 1 -- logger(LLDB_Debugger_Exploration.Logger) $R5 = 0x0000608000087e90 { currentClassName = "ViewController" debuggerStruct ={...} } By default LLDB will look infinitely into the object and show you a full description of every nested object: (lldb) e -- logger(LLDB_Debugger_Exploration.Logger) $R6 = 0x0000608000087e90 { currentClassName = "ViewController" debuggerStruct = (methodName = "name", lineNumber = 2, commandCounter = 23) } You can also explore object description with e -O -- or simply using alias po like in the example below: (lldb) po logger<Logger: 0x608000087e90> Not so descriptive, isn’t it? To get human-readable description you have to apply your custom class to CustomStringConvertible protocol and implement var description: String { return ...} property. Only then po returns you readable description. At the beginning of this section, I’ve also mentioned Basically print <expression/variable> is the same as expression -- <expression/variable>. Except 2. Get overall app’s state + language specific commands bugreport, frame, language How often have you copied and pasted and paste crash logs into your task manager to explore the issue later? LLDB has this great little command called bugreport which will generate a full report of current app’s state. It could be really helpful if you encounter some problem but want to tackle it a bit later. In order to restore your understand of app’s state, you can use bugreport generated report. (lldb) bugreport unwind --outfile <path to output file> The final report will look like example on the screenshot below: Let’s say you want to get a quick overview of the current stack frame in current thread. frame command can help you with that: Use snippet below to get a quick understanding where you are and what surrounding conditions are at the moment: (lldb) frame infoframe #0: 0x000000010bbe4b4d LLDB-Debugger-Exploration`ViewController.valueOfLifeWithoutSumOf(a=2, b=2, self=0x00007fa0c1406900) -> Int at ViewController.swift:96 This information will be useful in breakpoint management later in the article. LLDB has a couple of commands for a specific language. There are commands for C++, Objective-C, Swift and RenderScript. In this case, we’re interested in Swift. So here are these two commands: demangle and refcount. demangle as written in its name just demangle mangled Swift type name (which Swift generates during compilation to avoid namespace problem). If you’d like to learn more on that I’d suggest you watch this WWDC14 session — “Advanced Swift Debugging in LLDB”. refcount is also a pretty straightforward command. It shows you reference count for the specific object. Let’s see the output example with an object we used in the previous section — logger: (lldb) language swift refcount loggerrefcount data: (strong = 4, weak = 0) For sure, this could be quite useful if you are debugging some memory leaks. 3. Control app’s execution flow process, breakpoint, thread This part is my favorite. Because using these command from LLDB ( breakpoint command in particular) you can automate a lot of routine stuff during debugging. Which eventually speed up your debugging process a lot. With process you can basically control debug process and attach to a specific target or detach a debugger from it. But since Xcode does the process attachment for us automatically (LLDB is attached by Xcode every time you run a target) I won’t stop on that. You can read how to attach to a target using terminal in this Apple guide — “Using LLDB as a Standalone Debugger”. Using process status you can explore a current place where the debugger is waiting for you: (lldb) process statusProcess 27408 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x000000010bbe4889 LLDB-Debugger-Exploration`ViewController.viewDidLoad(self=0x00007fa0c1406900) -> () at ViewController.swift:69 66 67 let a = 2, b = 2 68 let result = valueOfLifeWithoutSumOf(a, and: b) -> 69 print(result) 70 71 72 In order to continue execution of the target until the next breakpoint occur, run this command: (lldb) process continue(lldb) c // Or just type "c" which is the same as previous command It’s the equivalent of “continue” button in the Xcode debugger toolbar: breakpoint command allows you to manipulate breakpoints in any possible way. Let’s skip the most obvious commands like: breakpoint enable, breakpoint disable and breakpoint delete. First things first, to explore all your breakpoints let’s use list sub-command like in the example below: (lldb) breakpoint listCurrent breakpoints: 1: file = '/Users/Ahmed/Desktop/Recent/LLDB-Debugger-Exploration/LLDB-Debugger-Exploration/ViewController.swift', line = 95, exact_match = 0, locations = 1, resolved = 1, hit count = 11.1: where = LLDB-Debugger-Exploration`LLDB_Debugger_Exploration.ViewController.valueOfLifeWithoutSumOf (Swift.Int, and : Swift.Int) -> Swift.Int + 27 at ViewController.swift:95, address = 0x0000000107f3eb3b, resolved, hit count = 12: file = '/Users/Ahmed/Desktop/Recent/LLDB-Debugger-Exploration/LLDB-Debugger-Exploration/ViewController.swift', line = 60, exact_match = 0, locations = 1, resolved = 1, hit count = 12.1: where = LLDB-Debugger-Exploration`LLDB_Debugger_Exploration.ViewController.viewDidLoad () -> () + 521 at ViewController.swift:60, address = 0x0000000107f3e609, resolved, hit count = 1 The first number in the list is a breakpoint ID which you can use to refer to any specific breakpoint. Let’s set some new breakpoint right from the console: (lldb) breakpoint set -f ViewController.swift -l 96Breakpoint 3: where = LLDB-Debugger-Exploration`LLDB_Debugger_Exploration.ViewController.valueOfLifeWithoutSumOf (Swift.Int, and : Swift.Int) -> Swift.Int + 45 at ViewController.swift:96, address = 0x0000000107f3eb4d In this example -f is a name of the file where you’d like to put a breakpoint. And -l is a line number of a new breakpoint. There is a shorter way to set the very same breakpoint with b shortcut: (lldb) b ViewController.swift:96 You can also set a breakpoint with a specific regex (function name, for example) using the command below: (lldb) breakpoint set --func-regex valueOfLifeWithoutSumOf(lldb) b -r valueOfLifeWithoutSumOf // Short version of the command above It’s sometimes useful to set a breakpoint for only one hit. And then instruct the breakpoint to delete itself right away. For sure, there is a flag for that: (lldb) breakpoint set --one-shot -f ViewController.swift -l 90(lldb) br s -o -f ViewController.swift -l 91 // Shorter version of the command above Now let’s tackle the most interesting part — breakpoint automation. Did you know you can set a specific action which will execute as soon as breakpoint occurs? Yes, you can! Do you use print() in the code to explore values you’re interested in for debugging? Please don’t do that, there is a better way. 🙂 With breakpoint command, you can setup commands which will execute right when the breakpoint is hit. You can even make “invisible” breakpoints which won’t interrupt execution. Well, technically these “invisible” breakpoints will interrupt execution but you won’t notice it if you add continue command at the end of commands chain. (lldb) b ViewController.swift:96 // Let's add a breakpoint firstBreakpoint 2: where = LLDB-Debugger-Exploration`LLDB_Debugger_Exploration.ViewController.valueOfLifeWithoutSumOf (Swift.Int, and : Swift.Int) -> Swift.Int + 45 at ViewController.swift:96, address = 0x000000010c555b4d(lldb) breakpoint command add 2 // Setup some commands Enter your debugger command(s). Type 'DONE' to end. > p sum // Print value of "sum" variable > p a + b // Evaluate a + b > DONE To ensure you’ve added correct commands use breakpoint command list <breakpoint id> sub-command: (lldb) breakpoint command list 2Breakpoint 2: Breakpoint commands: p sum p a + b Next time when this breakpoint hit we’ll get the following output in the console: Process 36612 resuming p sum (Int) $R0 = 6p a + b (Int) $R1 = 4 Great! Exactly what we’re looking for. You can make it even smoother by adding continue command at the end of the commands chain. So you won’t even stop on this breakpoint. (lldb) breakpoint command add 2 // Setup some commandsEnter your debugger command(s). Type 'DONE' to end. > p sum // Print value of "sum" variable > p a + b // Evaluate a + b > continue // Resume right after first hit > DONE So the result would be: p sum (Int) $R0 = 6p a + b (Int) $R1 = 4continue Process 36863 resuming Command #3 'continue' continued the target. With thread command and its subcommands you can fully control execution flow: step-over, step-in, step-out and continue. These are direct equivalent of flow control buttons on Xcode debugger toolbar. There is also a predefined LLDB shortcut for these particular commands: (lldb) thread step-over (lldb) next // The same as "thread step-over" command (lldb) n // The same as "next" command(lldb) thread step-in (lldb) step // The same as "thread step-in" (lldb) s // The same as "step" In order to get more information about the current thread just call info subcommand: (lldb) To see a list of all currently active threads use list subcommand: (lldb) thread listProcess 50693 stopped* thread #2: tid = 0x17df4a, 0x000000010daa4dc6 libsystem_kernel.dylib`kevent_qos + 10, queue = 'com.apple.libdispatch-manager' thread #3: tid = 0x17df4b, 0x000000010daa444e libsystem_kernel.dylib`__workq_kernreturn + 10 thread #5: tid = 0x17df4e, 0x000000010da9c34a libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.uikit.eventfetch-thread' Honorable mentions command, platform, gui In the LLDB you can find a command for managing other commands. Sounds weird but in practice, it’s quite useful little tools. First, it allows you to execute some LLDB commands right from the file. So you can create a file with some useful commands and execute them at once as if it would be a single LLDB command. Here is a simple example of the file: thread info // Show current thread info br list // Show all breakpoints And here is how the actual command looks like: (lldb) command source /Users/Ahmed/Desktop/lldb-test-scriptExecuting commands in '/Users/Ahmed/Desktop/lldb-test-script'br list Current breakpoints: 1: file = '/Users/Ahmed/Desktop/Recent/LLDB-Debugger-Exploration/LLDB-Debugger-Exploration/ViewController.swift', line = 60, exact_match = 0, locations = 1, resolved = 1, hit count = 0 1.1: where = LLDB-Debugger-Exploration`LLDB_Debugger_Exploration.ViewController.viewDidLoad () -> () + 521 at ViewController.swift:60, address = 0x0000000109429609, resolved, hit count = 0 There is also a downside, unfortunately, you can’t pass any argument to the source file (unless you’ll create a valid variable in the script file itself). If you need something more advanced you can always use script sub-command. Which will allow you to manage ( add, delete, import and list) custom Python scripts. With the script a real automation becomes possible. Please check out this nice guide on Python scripting for LLDB. Just for the demo, let’s create a script file script.py and write a simple command print_hello() which will just print “Hello Debugger!” in the console: Then we need to import a Python module and start using our script command normally: (lldb) command import ~/Desktop/script.pyThe "print_hello" python command has been installed and is ready for use.(lldb) print_helloHello Debugger! You can quickly check current platform information with a status subcommand. status will tell you: SDK path, processor architecture, OS version and even list of available devices for this SDK. (lldb) platform statusPlatform: ios-simulator Triple: x86_64-apple-macosx OS Version: 10.12.5 (16F73) Kernel: Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 Hostname: 127.0.0.1 WorkingDir: / SDK Path: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"Available devices: 614F8701-3D93-4B43-AE86-46A42FEB905A: iPhone 4s CD516CF7-2AE7-4127-92DF-F536FE56BA22: iPhone 5 0D76F30F-2332-4E0C-9F00-B86F009D59A3: iPhone 5s 3084003F-7626-462A-825B-193E6E5B9AA7: iPhone 6 ... Well, you can’t use LLDB GUI mode in the Xcode, but you can always do it from the terminal. (lldb) gui// You'll see this error if you try to execute gui command in Xcode error: the gui command requires an interactive terminal. Conclusion: In this article, I just scratched the surface of true LLDB’s power. Even though LLDB here with us for ages, there are still many people who don’t use its full potential. I have made a quick overview of basic functions and how LLDB can automate debugging process. I hope it was useful. So much LLDB functions were left behind. There are also some view debugging techniques which I didn’t even mention. If you are interested in such topic, please leave a comment below. I’d be more than happy to write about it. I strongly encourage you to open a terminal, enable LLDB and just type help. This will show you a full documentation. And you can spend hours reading it. But I guarantee this would be a reasonable time investment. Because knowing your tools is the only way for engineers to become truly productive. References and useful articles on LLDB - Official LLDB site — you’ll find here all possible materials related to LLDB. Documentation, guides, tutorials, sources and much more. - LLDB Quick Start Guide by Apple — as usual, Apple has a great documentation. This guide will help you to get started with LLDB really quickly. Also, they’ve described how to do debugging with LLDB without Xcode. - How debuggers work: Part 1 — Basics — I enjoyed this series of articles a lot. It’s Just fantastic overview how debuggers really work. Article describes all underlying principles using code of hand-made debugger written in C. I strongly encourage you to read all parts of these great series (Part 2, Part 3). - WWDC14 Advanced Swift Debugging in LLDB — great overview what’s new in LLDB in terms of Swift debugging. And how LLDB helps you be more productive with an overall debugging process using built-in functions and features. - Introduction To LLDB Python Scripting — the guide on Python scripting for LLDB which allows you to start really quickly. - Dancing in the Debugger. A Waltz with LLDB — a clever introduction to some LLDB basics. Some information is a bit outdated (like (lldb) thread returncommand, for example. Unfortunately, it doesn't work with Swift properly because it can potentially bring some damage to reference counting). Still, it’s a great article to start your LLDB journey.
https://medium.com/flawless-app-stories/debugging-swift-code-with-lldb-b30c5cf2fd49?source=---------4------------------
CC-MAIN-2019-39
refinedweb
2,926
56.25
Test your code with unit tests You have a piece of code and you want/need to test it. Let's get on with it! We will use a previous post as the code to test (you can find it here: Design Patterns: Factory Method) and will make use of Python's unit testing framework (unittest) to build our tests. Let's not get ahead of ourselves. First, a common testing practice: to test their code many developers write some function that makes use of it and check if it works properly. Let's check a possible example for our code. def test():name_factory = NameFactory()name1 = name_factory.get_name("Castro,Ricardo")name2 = name_factory.get_name("Pedro Teixeira")print name1.get_first(), name1.get_last()print name2.get_first(), name2.get_last() While this might be fine for our small example, that's not what we really need to properly test our code. Let's see a simple implementation for some tests and analyse it. import unittestfrom namer import NameFactoryclass TestNameFactory(unittest.TestCase):def setUp(self):self.name_factory = NameFactory()def test_firstfirst(self):name = self.name_factory.get_name("Pedro Teixeira")self.assertEqual(name.get_first(), "Pedro")self.assertEqual(name.get_last(), "Teixeira")def test_lastfirst(self):name = self.name_factory.get_name("Castro,Ricardo")self.assertEqual(name.get_first(), "Ricardo")self.assertEqual(name.get_last(), "Castro")if __name__ == '__main__':unittest.main() So, the main idea is to use unit tests to properly test our code. Like the name points out, unit tests aim at testing units of code. How can we do that? Python provides us a unit testing framework that we can use. We can then create a class that extends unittest.TestCase and, as we previous wrote a function to test our code, we can create as many functions as we want to test. By giving a quick look at the code, two points to notice here: - the methods representing test cases have to start with test; - there's a method called setUp. That method will be run before each test. An equivalent tearDown method will be run (if defined) after each test. As we can see, we're testing the output of the functions by using the assertEqual function but there's a lot more you can do. Check the unittest for more information about the framework. Personally, I think testing your code is extremely important. There are many advantages to testing your code properly, for example: - you can be sure that your code is working properly; - you have a way to show others that your code is working properly; - you can make changes to your code, and have a set of tests to make sure you haven't broke anything. I find this particularly useful when you have to change something and you run into the fear of breaking anything inadvertently. If you have a good test suite, by running your tests you can be sure you didn't break anything in the process. I can think of many other reasons, but I will leave you to find them out for yourself. Although the presented code here was written in Python, your favourite programming language should have some unit testing framework. Just search for it, read the docs and start using it. The underlying idea of this post is to write tests for your code. Like Nike: Just Do It.
https://mccricardo.com/test-your-code-with-unit-tests/
CC-MAIN-2021-25
refinedweb
548
65.52
Hi experts, I am using imx8mq board to develop rpmsg in my project. I am running Android 11.0.0_2.0.0. I flashed the M4 image along with Android images with "uuu_imx_android_flash.sh" script. And in uboot I set bootcmd as below: At first, M4 run normally as expected, But after few seconds, M4 program crashed and Android run normally. What's the problem maybe? Thanks Edward Hi Sirs: I follow this community to enable RPMSG function on Android 11_2.2.0 BSP, but there are booting issue, the dispaly is not enter Adroid UI, it only show "Android animation" logo on the HDMI . Do you have the same issue ? If yes, Could you let me know how to solved it? Thank a lot. Hi penny, No, I haven't this problem. I propose you double checking the dts again if any hardware resource has conflict. Thank your help. the issue solved. Great job. Have you used rpmsg communication between A53 and M4? Yes, remove m4_reserved node , the issue solved. ^^ --- a/arch/arm64/boot/dts/freescale/imx8mq-evk-rpmsg.dts +++ b/arch/arm64/boot/dts/freescale/imx8mq-evk-rpmsg.dts @@ -11,28 +11,19 @@ reserved-memory { #address-cells = <2>; #size-cells = <2>; - m4_reserved: m4@0x80000000 { - no-map; - reg = <0 0x80000000 0 0x1000000>; - }; + //m4_reserved: m4@0x80000000 { + // no-map; + // reg = <0 0x80000000 0 0x1000000>; + //}; You are welcome. Is it a dts issue caused the problem? Can you share your logs? Thanks, it solved by using UART4 not UART2. But till one problem happened, I run the rpmsg_lite_str_echo_rtos demo. Rpmsg channel has been created in Android(/dev/ttyRPMSG30 exists), and A53 sent "hello world!" to M4 successfully, but M4 cannot receive anything. Log in Android: [ 0.000000] OF: reserved mem: initialized node rpmsg_dma@0xb8400000, compatible id shared-dma-pool [ 0.313304] imx rpmsg driver is registered. [ 2.441396] imx_rpmsg_probe [ 2.444346] imx-rpmsg b8000000.rpmsg: assigned reserved memory node rpmsg_dma@0xb8400000 [ 2.452982] virtio_rpmsg_bus virtio0: rpmsg host is online [ 2.453012] virtio_rpmsg_bus virtio0: creating channel rpmsg-virtual-tty-channel-1 addr 0x1e [ 6.406768] rpmsg_tty_probe [ 6.409589] imx_rpmsg_tty virtio0.rpmsg-virtual-tty-channel-1.-1.30: new channel: 0x400 -> 0x1e! [ 6.418781] Install rpmsg tty driver! [ 6.422542] rpmsg_send hello world! success. And log in M4: RPMSG String Echo FreeRTOS RTOS API Demo... Nameservice sent, ready for incoming messages... I'd like to know why M4 cannot receive A53 message even rpmsg channel created between A53 and M4? I tested on Linux before, there is no issue. I will test on Android asap! Thanks. I also tested it on linux and it worked well. But it doesnot work on Android. I have tested our mcu demo image on Android.M core can accept audio from DirectAudioPlayer. #################### LOW POWER AUDIO TASK #################### Build Time: Jul 30 2021--08:48:03 ******************************** Wait the Linux kernel boot up to create the link between M core and A core. ******************************** The rpmsg channel between M core and A core created! ******************************** Task A is working now. No audio playback, M core enters STOP mode! Playback is running, M core enters RUN mode! Do you have any updates? Why do you always respond me a little not finish the question? Can you share your changes in Android source code? The Android11_2.0.0 demo images can't support M4 Firstly, I modified serveral files as below: 1. add below contents in imx8m/evk_8mq/SharedBoardConfig.mk BOARD_VENDOR_KERNEL_MODULES += \ $(KERNEL_OUT)/drivers/input/touchscreen/synaptics_dsx/synaptics_dsx_i2c.ko \ $(KERNEL_OUT)/drivers/input/touchscreen/synaptics_dsx/synaptics_dsx_i2c.ko 2. add below contents in imx8m/evk_8mq/BoardConfig.mk TARGET_BOARD_DTS_CONFIG += imx8mq-rpmsg:imx8mq-evk-rpmsg.dtbq 3. modify arch/arm64/boot/dts/freescale/imx8mq-evk-rpmsg.dtsvdev-nums = <1>; reg = <0x0 0xb8000000 0x0 0x10000>; - memory-region = <&vdevbuffer>; - status = "disabled"; + memory-region = <&rpmsg_dma_reserved>; + status = "okay"; Secondly, compiple the image and flash to your board use below command in ubuntu ./uuu_imx_android_flash.sh -f imx8mq -e -m remember to name the dtbo-imx8mq-rpmsg.img to dtbo-imx8mq-rpmsg.img and the m4 bin named as imx8mq_mcu_demo.img when flash image to your board Thirdly, enter uboot and modify bootcmd as: setenv bootcmd "bootmcu && boota mmc0" Can you share your imx8mq-evk-rpmsg.dts? I found that my dts file is different from your dts Thanks for your quick reply. I'd like to know which board did you use. And could you share you dts and which android version or linux kernel version did you use? Could you test the rpmsg_lite_str_echo_rtos demo? Sure, it is like below which I reference : // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* */ /dts-v1/; #include "imx8mq-evk.dts" / { reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; m4_reserved: m4@0x80000000 { no-map; reg = <0 0x80000000 0 0x1000000>; }; rpmsg_reserved: rpmsg@0xb8000000 { no-map; reg = <0 0xb8000000 0 0x400000>; }; rpmsg_dma_reserved:rpmsg_dma@0xb8400000 { compatible = "shared-dma-pool"; no-map; reg = <0 0xb8400000 0 0x100000>; }; }; }; /* * Regarding to the HW conflications, the following module should be disabled * when M4 is running on evk board. * gpt1, i2c2, pwm4, tmu, uart2 */ &i2c2 { status = "disabled"; }; &pwm4 { status = "disabled"; }; &rpmsg{ /* * 64K for one rpmsg instance: * --0xb8000000~0xb800ffff: pingpong */ vdev-nums = <1>; reg = <0x0 0xb8000000 0x0 0x10000>; memory-region = <&rpmsg_dma_reserved>; status = "okay"; }; &tmu { status = "disabled"; }; &uart2 { status = "disabled"; }; The rpmsg dts file in 5.10.x is not using node &rpmsg, you can try to remove it.As we have reserved the M4 memory.The official imx8mq-evk-rpmsg.dts have supported M4 demo program. reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; m4_reserved: m4@0x80000000 { no-map; reg = <0 0x80000000 0 0x1000000>; }; vdev0vring0: vdev0vring0@b8000000 { reg = <0 0xb8000000 0 0x8000>; no-map; }; vdev0vring1: vdev0vring1@b8008000 { reg = <0 0xb8008000 0 0x8000>; no-map; }; rsc_table: rsc_table@b80ff000 { reg = <0 0xb80ff000 0 0x1000>; no-map; }; vdevbuffer: vdevbuffer@b8400000 { compatible = "shared-dma-pool"; reg = <0 0xb8400000 0 0x100000>; no-map; }; }; imx8mq-cm4 { compatible = "fsl,imx8mq-cm4"; rsc-da = <0xb8000000>; clocks = <&clk IMX8MQ_CLK_M4_DIV>; mbox-names = "tx", "rx", "rxdb"; mboxes = <&mu 0 1 &mu 1 1 &mu 3 1>; memory-region = <&vdevbuffer>, <&vdev0vring0>, <&vdev0vring1>, <&rsc_table>; syscon = <&src>; }; I tried as you said. But it did not work. /dev/ttyRPMSG* did not apper, how to communicate with M4. Could you run the demo in your side? Thanks. Thanks. Have you tried it and does it work in Android?
https://community.nxp.com/t5/i-MX-Processors/imx8mq-Android11-load-M4-crashed/m-p/1446854
CC-MAIN-2022-40
refinedweb
1,037
68.97
Oh, what a tangled web. That’s why so many languages focus on using braces and brackets, because they are free and easy to type. Though, once you’ve allocated them to one purpose you cannot readily reallocate them to another. You can try to overload them, and give them some contextual dependency, but that usually ends up in a mess. I know, I advocated for a long time using the brackets as a filter operator for the X# language. I even built in all the contextual baggage into the compiler so it would fundamentally work, most of the time. In the end it was a wash. If I could do it all over again, I’d find another way. We get into this same trouble when designing new features for C#. Symbols to use as new operators are scarce. It’s even worse with keywords, you cannot make new ones. That would break backward compatibility of the code. Sure, C# 2.0 pulls some tricks and lets in some new terms in novel places, but you can only do this so much before that avenue dries up. We bat around ideas about how to solve this problem once and for all. Sometimes it seems like we spend way too much time thinking about it. But, you know, eventually hard work does pay off. In fact, I’ve come up with a solution that should suffice for all .Net languages. I’m not certain, but it might be applicable to other languages as well. Fortunately, for Microsoft, I’ve already filed the patent on it. It’s been a while, but legal has finally given me the go ahead to fully disclose it now. You see the trouble really lies in the in-ability to set pieces of the language apart. What you want to do is have a mechanism you can use to specify that a term is always special to the language, so that it can never be used by an application as a variable name or some other identifier. Doing that solves the backward code compatibility problem. However, there is still only a small set of common symbols on the keyboard, so it’s not easy to find one. Sure, you could imagine using other symbols available in the Unicode character set, but then you’d have to invent new keyboards to use just for the language, and I don’t want to re-invent the APL nightmare. Still, if you had a spare symbol or two you could come up with a bracketing mechanism to set your keywords apart. Some languages do this with a dollar-sign ($) prefix, other languages have other means. But this is an ugly solution. Extraneous symbols just get in the way of readability, and if you know anything about maintainability of code, you don’t want anything hindering you ability to read and understand it. So I found myself perplexed one day last month, wanting to solve the problem but having no luck. I’d tried just about every combination of symbols that I could think of, and yes I even tried putting keywords inside quotes, but it just looked bad. I would try each one out using the IDE and put it in context with fragments of code. Anders does this a lot when he’s working through a new idea, and it always seems to work for him. I try to learn new tricks like this whenever I can. Still it wasn’t helping. Have you every tried to seriously read code that wrapped keywords in something like dots? Try it .foreach.(int x .in. numbers) … Now tell me, is that a usable solution? And that was the best one. I just could not bear to end up with a language that looked like FORTRAN, could you? So as I said, I was perplexed. I was intellectually exhausted at this point. It had been weeks and still nothing. But, you know, that’s exactly the time when breakthroughs happen. I was weary and almost to the point of beating my forehead into the monitor, when suddenly I saw something. It was less of a thought and more of an optical illusion, a trick of the light, like when you eyes lock onto one of those mystery-eye puzzles, and then you truly see what has been there all along. It hit me so fast I found I could not breathe. The answer had been right in front of me the whole time. I had been staring at a fragment of normal looking code, ready to be cut-and-pasted into yet another bad idea. public class Foo { public int X; public float Y; } The answer was so simple it shook me to the bones. We did not need new symbols. Symbols got in the way. We had something so powerful already that not only got out of the way, it enhanced readability. I’m talking about the blue. Keywords are blue. Everyone already knew this, but no one had ever seen it for what it truly was, for what potential it truly had. It was the big jump that made the IDE experience so powerful. Code was easier to read because of it, and it didn’t get in the way of reading the words. Text has color. Color has meaning. Keywords are blue. Believe me, from now on programming will never be the same. Sure it sucks for people using notepad or third party editors, but you cannot stand in the way of innovation! Keep programming in the blue. Matt PingBack from
http://blogs.msdn.com/mattwar/archive/2004/03/08/86354.aspx
crawl-002
refinedweb
934
74.19
Introduction Purpose The purpose of this project is to control a Linux Ansible controller through Windows. Idea inception The original idea originated from this trying to automate an IDAM solution called BeyondTrust. BeyondTrust wasn't meant to be automated, so it was a pretty daunting task through Ansible. Proposed Solution I wanted to create a solution for dumb users who aren't familiar with the Linux environment and for those who aren't familiar with Ansible. I wanted to create a Windows solution, since most people are familiar with Windows and know how to double-click an executable. Why Python? Libraries One of the main reasons I love using Python is for their extensive library selection. I know that if I have thought of something I want, someone has most likely already found a solution. The libraries I am using are located below: import tkinter import configparser import sys import logging import paramiko import os Previous knowledge (familiarity) I often think it's important to use something you are familiar with. There may be a better tool that does more and has more bells-and-whistles. However, it's important to stick with what you know, especially in a time sensitive situation. I could have easily learned a better language for application development. I'm sure there are better systems out there that are more efficient, require less code, consume less resources, etc. It was important for me to stick to my guns, Pythons. One of the requirements I self-imposed was a 3 week deadline. I felt 2 weeks was too fast and 4 weeks prolongs it and promotes procrastination. I wanted to avoid both situations; I felt that 3 weeks was a good medium. Being able to resort to Python, knowing that whatever I encounter Python has an answer. Python also has an extremely large community. From what I have seen on Reddit and Stackoverflow, much more helpful too ;) Resources Used Hosting and Collaboration Tools I will be utilizing AWS cloud services to help accomplish this project. - AWS EC2 - AWS Cloud9 For code management and versioning I set up a Github private repository. Getting Help So I knew I couldn't accomplish this project on my own within the time frame I set. So I crowdsourced for help. Two other people are working on this project with me. I don't know them, but I have to give them proper credit because without their help this project would never have gotten done. Python IDE (KISS) The IDE I chose to work with is the Python IDE. I like to follow a simple philosophy - Keep It Simple Stupid (KISS). Keeping my working environment as bare bones as possible allows me to learn and understand what I am doing more, because I am at the wheel. It's like driving a manual compared to an automatic. Both are great and have their benefits, choose what fits you. I remember being made fun of by my college professors in my Java 101 class for using JGRASP, jokes on them - I got a B. Concept Design and Thoughts The first design was based around the BeyondTrust stack. It was intended to just call an Ansible playbook based on the selections made. This design would work really well for a single product deployment. The problem is that it doesn't follow any good dynamic design principles. It's extremely linear and doesn't allow for expandability. The next design concept takes all of that BeyondTrust stuff and chucks it out the window. Instead of focusing on one product, why not allow the user to execute any playbook the way they wanted to using Linux syntax? This is where I believe the final iteration of the product will end up. This design allows the product to be more dynamic and not locking it into a single use case. Sharing Code Creating an Ansible Hosts file based on system type and service. Note: this isn't final, but it provides a general understanding on how to create a more dynamic inventory based on the service you want to the target hosts. Reminder I want to remind everyone this project is still in progress. I am looking for help if anyone would like to contribute. Discussion (0)
https://dev.to/schnipdip/making-a-windows-python-application-to-manage-linux-ansible-1502
CC-MAIN-2021-49
refinedweb
711
63.59
Solution for Programmming Exercise 8.4 This page contains a sample solution to one of the exercises from Introduction to Programming Using Java.: A pseudocode algorithm for the program is given by: while (true): Get a line of input from the user if the line is empty: break Convert the input line to an Expr Read and process the user's numbers Converting the input line into an object of type Expr involves calling the constructor from the Expr class. This call might generate an IllegalArgumentException. The algorithm must be expanded to handle this exception and print an error message if it occurs. When an error occurs, I use a continue statement to jump back to the start of the loop without reading any numbers from the user: while (true): Get a line of input from the user if the line is empty: break try { Let expression = new Expr(line) } catch (IllegalArgumentException e) { Print an error message continue // jumps back to start of loop } Read and process the user's numbers The last step, reading and processing the user's numbers, expands into a loop, which is nested inside the main while loop. In this loop, I could use TextIO.getDouble() to read one of the user's numbers, but instead I choose to read the user's input into a string and convert that string into a value of type double. This has two advantages: I can end the loop when the user presses return. And I can do nicer error handling than the default error-handling that is provided by TextIO. The conversion from a string, line, to a double is done using a method Double.parseDouble(string). The conversion will generate a NumberFormatException if the user's input is not a legal number. The algorithm for reading and processing the user's numbers becomes: while (true): Get a line of input from the user if the line is empty: break try { Let x = Double.parseDouble(line) } catch (NumberFormatException e) { Print an error message continue } Let val = expression.value(x) if val is Double.NaN: Print an error message else: Output val All this can be easily translated into the complete solution, which follows. public class FunctionEvaluator { public static void main(String[] args) { String line; // A line of input read from the user. Expr expression; // The definition of the function f(x). double x; // A value of x for which f(x) is to be calculated. double val; // The value of f(x) for the specified value of x. TextIO.putln("This program will evaluate a specified function, f(x), at"); TextIO.putln("specified values of the variable x. The definition of f(x)"); TextIO.putln("can use the operators +, -, *, /, and ^ as well as mathematical"); TextIO.putln("functions such as sin, abs, and ln."); while (true) { /* Get the function from the user. A line of input is read and used to construct an object of type Expr. If the input line is empty, then the loop will end, and the program will terminate. */ TextIO.putln("\n\n\nEnter definition of f(x), or press return to quit."); TextIO.put("\nf(x) = "); line = TextIO.getln().trim(); if (line.length() == 0) break; try { expression = new Expr(line); } catch (IllegalArgumentException e) { // An error was found in the input. Print an error // message and go back to the beginning of the loop. TextIO.putln("Error! The definition of f(x) is not valid."); TextIO.putln(e.getMessage()); continue; } /* Read values of x from the user, until the user presses return. If the user's input is not a legal number, print an error message. Otherwise, compute f(x) and print the result. */ TextIO.putln("\nEnter values of x where f(x) is to be evaluated."); TextIO.putln("Press return to end."); while (true) { TextIO.put("\nx = "); line = TextIO.getln().trim(); if (line.length() == 0) break; try { x = Double.parseDouble(line); } catch (NumberFormatException e) { TextIO.putln("\"" + line + "\" is not a legal number."); continue; } val = expression.value(x); if (Double.isNaN(val)) TextIO.putln("f(" + x + ") is undefined."); else TextIO.putln("f(" + x + ") = " + val); } // end while } // end while TextIO.putln("\n\n\nOK. Bye for now."); } // end main(); } // end class FunctionEvaluator
http://math.hws.edu/javanotes/c8/ex4-ans.html
crawl-001
refinedweb
697
59.09
- Type: Bug - Status: Closed - Priority: P1: Critical - Resolution: Done - Affects Version/s: 5.5.0 - - Component/s: Quick: Controls 1, Quick: Core Declarative QML - Labels: - Environment:Mac OS X 10.10.4, Xcode 6, Qt 5.5.0 (release) - Platform/s: - Commits:9b8d0bffdafeb4dd9b256113716c07f2c49f3903 ScrollView bounce is broken when using Macbook's Touchpad or Apple Magic Mouse on Mac OS X. It either scrolls too far away and sticks in that position, or the scrolling wraps around and continues from the bottom. ScrollView is almost unusable, please see the attached video. Caused by this commit: cd qtdeclaractive/ git revert a6ed830f4779e218b8e8f8d82dc4aa9b4b4528a1 Possibly related issue: Attached is a test project. main.qml: import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Window 2.0 import QtQuick.Dialogs 1.2 ApplicationWindow { title: qsTr("Hello World") width: 640 height: 480 visible: true ScrollView { anchors.fill: parent flickableItem.interactive: true Flickable { interactive: true contentHeight: row.height contentWidth: row.width Row { id: row Repeater { model: 100 Column { Repeater { model: 100 Text { text: index } } } } } } } } - is duplicated by QTBUG-53386 [Reg 5.7] Flickable misbehaves on OSX with trackpad - Closed - is related to QTBUG-44514 ScrollView: don't need to correct for Flickable shortcomings anymore - Open - relates to QTBUG-53177 Flickable: when flicking quickly with the Apple Trackpad, when it hits the end, it bounces twice - Closed QTBUG-56654 [iOS][REG 5.6.1->5.7.0] After scrolling in a ListView then the list can end up scrolling back to the bottom - Closed QTBUG-36771 Grabbing ListView (Flickable) while playing the rebound animation causes the flickable to jump - Closed QTBUG-55871 Flickable::movementEnded() not emitted when dragging on macOS - Closed - resulted from QTBUG-22407 Scrolling qml Flickable on mac - Closed
https://bugreports.qt.io/browse/QTBUG-47697
CC-MAIN-2020-16
refinedweb
284
57.77
Join on time Use join.time() to join two streams of data based on time values in the _time column. This type of join operation is common when joining two streams of time series data. join.time() can use any of the available join methods. Which method you use depends on your desired behavior: inner (Default): Drop any rows from both input streams that do not have a matching row in the other stream. left: Output a row for each row in the left data stream with data matching from the right data stream. If there is no matching data in the right data stream, non-group-key columns with values from the right data stream are null. right: Output a row for each row in the right data stream with data matching from the left data stream. If there is no matching data in the left data stream, non-group-key columns with values from the left data stream are null. full: Output a row for all rows in both the left and right input streams and join rows that match based on their _timevalue. Use join.time to join your data Import the joinpackage. Define the left and right data streams to join: - Each stream must also have a _timecolumn. - Each stream must have one or more columns with common values. Column labels do not need to match, but column values do. - Each stream should have identical group keys. For more information, see join data requirements. Use join.time()to join the two streams together based on time values. Provide the following parameters: left: (Required) Stream of data representing the left side of the join. right: (Required) Stream of data representing the right side of the join. as: (Required) Join output function that returns a record with values from each input stream. For example: (l, r) => ({r with column1: l.column1, column2: l.column2}). method: Join method to use. Default is inner. The following example uses a filtered selections from the machineProduction sample data set as the left and right data streams. Example data grouping The example below regroups both the left and right streams to remove the _field column from the group key. Because join.time() only compares tables with matching group key instances, to join streams with different _field column values, _field cannot be part of the group key. import "influxdata/influxdb/sample" import "join" left = sample.data(set: "machineProduction") |> filter(fn: (r) => r.stationID == "g1" or r.stationID == "g2" or r.stationID == "g3") |> filter(fn: (r) => r._field == "pressure") |> limit(n: 5) |> group(columns: ["_time", "_value", "_field"], mode: "except") right = sample.data(set: "machineProduction") |> filter(fn: (r) => r.stationID == "g1" or r.stationID == "g2" or r.stationID == "g3") |> filter(fn: (r) => r._field == "pressure_target") |> limit(n: 5) |> group(columns: ["_time", "_value", "_field"], mode: "except") join.time(method: "left", left: left, right: right, as: (l, r) => ({l with target: r._value})).
https://docs.influxdata.com/flux/v0.x/join-data/time/
CC-MAIN-2022-40
refinedweb
485
76.72
Feeding your inner nerd Subscribe Filed under IIS , php , websites ,: That's it. You're all done! Nice and easy. Nov29 Filed under IIS , websites. I double checked IIS6 and confirmed that the new runtime was in effect. However, every time I tried to load the website I was seeing the 'Server Application Unavailable' error message. I checked the Event logs and nothing was mentioned in there so that was no help. I double checked all the settings and everything seemed correct. Then it hit me. I had updated the framework but not refreshed the application pool for this website. Sure enough, once I refreshed the application pool the site came to life. I just wish IIS had some better error messages to help work around these situations. A simple prompt telling me that the application pool runtime wasn't matching the website runtime would have pointed me in the right direction. Ah well, at least I know in future it this happens again :) Oct18 Filed under C# , mvc , websites. You could write your own extension to handle the cookie creation and management but you might find it easier to use a third party library called FormsAuthenticationExtensions This extension can be installed using Nuget: Install-Package FormsAuthenticationExtensions Once installed you can use it very easily by adding the following code to your application where the user's is being logged in: using FormsAuthenticationExtensions; public bool Login(string userName, string password) { // handle your own logic to check the username and password and log in the user // if the login is successful, store some additional details into the session ticket if (User.Identity.IsAuthenticated) { var user = // make a database call to get this user's name and email address var ticketData = new NameValueCollection { { "firstname", user.Firstname }, { "surname", user.Surname }, }; new FormsAuthentication().SetAuthCookie(userName, true, ticketData); } return loggedIn; } As you can see the above code will take the user's email and name and store it along with the session cookie. To read the values from the cookie in your MVC controller you can use something like this: using FormsAuthenticationExtensions; public ActionResult MyContactDetails() { // get the email from cookie var ticketData = ((FormsIdentity)User.Identity).Ticket.GetStructuredUserData(); var emailFromCookie = ticketData["id"]; return View(); } Or if you want to display the cookie details in your razor view you can do this: @using FormsAuthenticationExtensions; @{ var ticketData = ((FormsIdentity)User.Identity).Ticket.GetStructuredUserData(); } Finally, if you need to update any of the details in the cookie (for example, if the user updates their email address) you can simply do something like this: using FormsAuthenticationExtensions; [HttpPost] public ActionResult MyContactDetails(ViewModel model) { // check cookie for data var ticketData = ((FormsIdentity)User.Identity).Ticket.GetStructuredUserData(); if (ModelState.IsValid) { // update some of the cookie information with the new data ticketData = new NameValueCollection { { "firstname", model.Firstname }, { "surname", model.Surname }, }; new FormsAuthentication().SetAuthCookie(model.Email, true, ticketData); return RedirectToAction("MyContactDetailsSuccess"); } return View(model); } As you can see it's very easy to use and a great way of storing small data in your app to help cut down on database calls. You need to be a little careful with this and ensure that you only store the bare minimum of information here. Cookies can't be too large so if you have anything more than 3-5 additional string data types and you might want to look at using a Session value instead. You should also avoid storing any complex data types in your cookies. Jun22 Filed under General , websites I've been really busy over the last few months planning some really cool new projects that I'd like to launch during the year. As a side effect my own blog hasn't been updated as much as I'd have liked. Fear not though as I have some new posts that I'm currently working on that should be online shortly (fingers crossed!). One new side project I have just launched is Stuff4Designers.com, a website dedicated to bringing you the best web resources and inspiration for web designers from around the interwebs. Rebecca FitzGerald-Smith is co-owner with me on this site. Go check it out and if you have any design ideas or showcases be sure to let us know! Jan16 Filed under General , Online Stores , websites. Nov20 A good friend of mine recently setup a new website, urbanspaceinitiative.com, that discusses the connection that exists between urban public space and the life of urbanites through the lens of geographical imagination, urban design, art and urban culture. My friend was looking for a simple logo to help jazz up his site a little. I created the image above using Adobe Fireworks and, thankfully, he was pretty chuffed with how it turned out and it's now live on his website :) I'd encourage anyone interested in public space imagery to head on over to his site. He has some beautiful imagery on the site and his articles go into great depth on the subject of public spaces. Nov01. This guide isn't for regular internet designers or developers but people who might never have owned a website before. These points are all common sense to people who work in the industry but for someone starting out you'd be surprised how many of these points get overlooked. A lot of these points are also just good business tips. This is also a nice follow on guide to my tips for running an online store that I posted in the middle of last year. Don't expect to get rich overnight - This is one of the most common problems I see. People expect to be "Internet millionaires" as soon as their new website or online store launches only to find that 'Hey, this thing requires a lot of work to get off the ground'. One thing I always tell them is that if this was a get rich quick scheme I'd be loaded by now but unfortunately it's not. Like any new business, it requires a lot of hard work, late nights, and constant marketing to get a new website noticed. Update your content regularly - You can spend thousands on marketing your website, get the most expensive designer to create a beautiful theme for your store or go to every 'How to run your website' conference going but unless you keep your site fresh by updating the content regularly then people just won't come back. Answer emails or phone calls from users of your site - New business owners are often a little shy starting off. It's OK, it's natural. Being nervous at the start of your business career is expected but never ignore a phone call or an email from a user on your website. You never know what the user might want. They could be calling to offer you tons of money (doubtful) or just to check if you can deliver item X from your site by next Monday if they order today. No one expects you to work 24hr/7 days a week but even a quick 'Thanks, I'll follow up in the morning' mail would be ideal to let the user know that you got their mail and will be in touch when you get a chance. Request feedback from your users - Always have a contact form on your site. I'm always amazed at the number of clients who don't want to receive any emails or calls from site users. Think of all the missed sales opportunities you would have without a phone. It's the same thing with a contact form. If you run an online store I would also strongly suggest you put up a contact number for people to call if they have any queries. It all helps add to the confidence for the end user that your website is a proper, legit organization. Follow up on any enquires or sales queries - Never expect the customer to come back to you about a question they asked a few days ago. If a user asks you about a service you offer or a product for sale then follow up with the user after a week if you hear nothing from them. Never harass the user by sending 44 emails in 30mins. Just a simple one liner asking if they require any further assistance or if they have further questions is all you need to do here. Do market your new site as best you can - Ok, I know. You've read this one a million times already on other blogs. You need a blog, a Facebook account and a Twitter account, blah blah blah. Unless you are someone who is going to keep site content up to date (see point 2 above) then be careful going down this route. Nothing stands out more than a dead twitter account with 5 posts from that week 12 months ago when you first set it up or from a blog on your site with only 3 posts. Dead social networking accounts are not marketing. If you don't have loads to say then look into Google AdWords or something similar. Don't overlook tradition marketing mediums either. TV, radio and newspapers are still enjoyed by millions of people. Market your site where your customers will be. If you run a website about fishing then advertise in fishing magazines or local free ads if that's where your customer base will be. Be smart about your marketing and don't let the web designer force you into setting up expensive ad words or pointless online accounts. Interact with your users - When you have a new website there is nothing harder than getting the name out there. Marketing can help when it's done right, as I've mentioned in the point above. Another option you can do is to offer competitions or polls for users to come to your site and give you feedback on. If you offer services then allow web users to avail of discounts if they make a booking online. If you run a store offer free post to all orders of a certain amount. It all helps make the user think they are getting a benefit for using your site. Allow users to send links from your site to their friends - A good trick to do on a website is to allow the end user to send a link to the page they are viewing to their friend. Nothing gets your site noticed faster than word of mouth. Make it as easy as possible for end users to spread the word and you're nearly half way there. Spend your money wisely - You've spent money getting your website or new online store made, you show it to some friends and family and then they come back to you and say 'love it but it's missing feature X'. I don't know how many times I see this with new website owners. They all fall into the same trap of thinking that they need to have this feature on their site for it to success. They're losing millions because it's not online. How could we all have overlooked such an obvious feature?! You can have as many whizz bang features as you want on your site, you can spend thousands building them but unless you have the business basics in place you're wasting your time. All the features in the world are not going to get your site noticed. You need to focus on marketing and getting the name out there first. All the new super features can wait until version 2 of your site. Of course, no web designer or developer will tell you otherwise as we will happily take your hard earned cash if you want to spend it so keep asking yourself if you need this new feature or if you would just like to have it. So there you have it. These points are just some little tips to help get you started on your web master journey. The key points are really just what any new business requires to make it - marketing, keep clients happy so they tell their friends and hard work keeping your site up to date with fresh content to encourage users to come back to you. Let me know in the comments if you think I've overlooked anything. If you're a new website owner why not let me know how you're getting on or if you have any tips for other new website owners out there? Jun09
http://www.reddybrek.com/category/websites.aspx
CC-MAIN-2013-20
refinedweb
2,094
68.7
Rating: 4 Article information Article relates to RadControls for WinForms Created by Nikolay Diyanov Last modified Oct. 02, 2007 Last modified by HOW-TO Host RadControls for WinForms in Internet Explorer SOLUTION It is easy to host RadControls for WinForms in Internet Explorer. Please follow the steps below to set up control hosting: Right-click it and select Properties , then the Web Sharing tab. Choose the Share This Folder radio button and a Edit Alias window will appear. Then click OK and then OK once again to save the Virtual Directory properties. Create a new Windows Control Library project in Visual Studio and name it, for example IEHostUIControl Right-click on the project file in the Solution Explorer and choose Properties. Select the Build tab and change the Output path to the virtual directory path. Add a new item to the project: right-click the project file, then select Add -> New Item... .Choose User Control item, name it, for example UserControl1.cs and click Add . Double-click UserControl1.cs in the Solution Explorer and now you can add RadControls by dragging them from the toolbox to the UserControl1 Design View . Build the project. A IEHostUIControl.dll file should appear in the VirtualDir . Now that you have the assembly containing the controls, you should create a html page, that will host this assembly. Create a simple html page in the VirtualDir, name it index.htm , then in the body tag add a tag of type object, which references the assembly and the type in its classid property in the way shown below. In the example below, IEHostControl.dll is the assembly, that we have just created in the VirtualDir directory. As for " IEHostUIControl.UserControl1 ", IEHostControl is the namespace, and the UserControl1 is the user control item created. You have to reference the type in the classid property the type as follows: <the name of the DLL>#<namespace name>.<type name> This is illustrated in the example below: <object id="simpleControl1" classid="http:IEHostUIControl.dll#IEHostUIControl.UserControl1" height="300" width="300"> </object> In order to be able to view the hosted controls in the web page, you have to set the necessary permissions. Start Internet Explorer , choose Tools , Internet Options , then open the Security tab. Click on Trusted Sites and then the Sites button. In our case, the site is located on the local hard drive, so add " " to the trusted sites, and uncheck Require server verification (https:) for all sites in the zone . Depending on your server configuration you should use one of the following approaches: Using Microsoft .NET Framework 2.0 Configuration There is one final thing that you have to change with the permissions. Go to the Control Panel >> Administrative Tools >> Microsoft .NET Framework 2.0 Configuration . From the tree on the left navigate to Runtime Security Policy >> Machine >> Code Groups >> Trusted Zone . From the panel on the right, open Edit Code Groups Properties and then, the Permission Set tab. Set Permissions to FullTrust and click OK . Using Code Access Security Policy Tool If you are working on a non-developer workstation, Microsoft .NET Framework 2.0 Configuration will not be available . In this case you should use the Code Access Security Policy Tool (caspol.exe) instead. You can find it in the " C:\WINDOWS\Microsoft.NET\Framework2.0.50727\ " directory. The directory name varies, depending on the drive that has Windows installed, and the specific version of .NET Framework that you have. To use the Caspol utility, open the command line, navigate to the directory mentioned above and then type " caspol -machine -chggroup 1.5. FullTrust ", where "1.5." stands for the Trusted Zone . However, Trusted Zone could be under different number in your case, so you should first check this by typing the command " caspol -m -lg ". It will list all the zones with their corresponding numbers and security levels. NOTE: You also can set the security level just for one assembly by using the command " caspol -addfulltrust C:\VirtualDir\IEHostUIControl.dll ". Note, that this command will work only if the IEHostUIContro.dll is strongly named. To give the assembly a strong name, please refer to the following MSDN article. Start Internet Explorer and type the URL of your virtual directory: . You should get the page you created with the hosted RadControls . There is one problem with this article; The Microsoft .NET Framework 2.0 Configuration mentioned is not available on non-developer workstations since it only comes with the full SDK (which is a > 150 Mbyte install). I would suggest that you change the text to use the Caspol utility instead, that utility is installed with the .NET 2.0 framework, as is thus present on all systems. Thank you for your comment, Jonny. We have updated the article to include information on using the Caspol utility. We will be glad to hear your further feedback.
http://www.telerik.com/support/kb/winforms/general/host-radcontrols-for-winforms-in-internet-explorer.aspx
crawl-003
refinedweb
810
58.48
Author: Peter Schrammel Almost nobody likes writing unit tests – and if you agree, you may be glad to hear that manually writing all of your tests is becoming a thing of the past. We’ve developed Diffblue Cover, an AI tool that automatically creates unit tests for Java code, to make it easier to get the unit tests you need without spending the time it takes to write them. Diffblue Cover: Community Edition is a free IntelliJ plugin that uses the same core technology, and is now available for anyone to use with their open-source Java projects. What does Community Edition do? So how is it actually used? Diffblue Cover works like this: First, Diffblue Cover ensures that your code is compiled. This is required because it performs an analysis on the bytecode. Then, it tries to trigger executions of paths through each method that it is going to test, using inputs that are similar to those a developer would choose. On the way, it mocks any dependencies that should be mocked. Finally, it figures out what the useful assertions may be and adds them to the test. Note that the assertions always reflect the current behavior of the code; Diffblue Cover is not able to anticipate your intentions and ‘fix’ the code for you. Diffblue Cover is intended to be used for unit regression testing. Essentially, this means it creates unit tests that reflect the current behavior of your code (and if you’d like more information about that, we have an explanation here). If your code is currently working, Diffblue Cover captures this. Later, when you make changes to the code, these tests may fail and show you possibly unintended changes to the code (so-called “regressions”). It can also help you find bugs by review. What this means for developers Diffblue Cover is significantly faster than writing manual tests from scratch. Sometimes it might not succeed in finding a suitable test for your code, in which case it may return a partial test for you to complete. But because Diffblue Cover creates unit tests in bulk in a tiny fraction of the time it’d take to write them, it helps you speed up unit test writing for new features. Currently, Diffblue Cover is only available for Java, but will be expanded to work with other languages in the future. Generated unit tests that look like they were written by a person The tests that Diffblue Cover creates largely follow the arrange-act-assert pattern: - Arrange inputs and mocks - Act: run method under test - Assert effects Here’s an example that Cover created: @MockBean private AmazonS3Client amazonS3Client; ); S3Object actualS3Object = this.cloudStorageService.downloadFileFromBucket("bucket-name", "key") assertSame(s3Object, actualS3Object); } Installation and first steps You can download the plugin here, or by going to Preferences > Plugins > Marketplace in your IntelliJ IDE, searching for “Diffblue Cover,” and installing the community edition. To give you an idea of what the tool does and illustrate its features, let’s look at a simple example project that uses the Spring framework: Spring Pet-Clinic. We have forked this project into. You’ll find the branches for each lesson of this tutorial so that you can follow along on your own. Your first steps after having installed the plugin are: - git clone - cd Spring-petclinic - git checkout a-test-intro - Open project in IntelliJ - Navigate to the CloudStorageService class This class implements a simple service for uploading to and downloading files from an S3 bucket. @Service public class CloudStorageService { @Autowired private AmazonS3 s3client; public PutObjectResult uploadFileToBucket(String bucketName, String key, File file) { return s3client.putObject(bucketName, key, file); } public S3Object downloadFileFromBucket(String bucketName, String key) { return s3client.getObject(bucketName, key); } To create tests for this class, right-click on CloudStorageService > Write tests When you open the event log, you’ll see what the tool is doing. First, it ensures that the project compiles and figures out for which methods we want to produce unit tests. To create the tests, it has to load the Spring context and find suitable inputs to the methods to exercise paths through these methods. Once the first test has been created you can navigate to the created test source file to see the tests. Further tests will drop in as they are produced. Let’s have a look at this test. The tested service would communicate with an actual S3 bucket. We don’t want this to happen in a unit test, so we mock the S3 client using Mockito. We have to set up the object returned by getObject appropriately, including the content of the file. @ExtendWith(SpringExtension.class) public class CloudStorageServiceTest { @MockBean private AmazonS3Client amazonS3Client; @Autowired private CloudStorageService cloudStorageService; ); assertSame(s3Object, this.cloudStorageService.downloadFileFromBucket("bucket-name", "key")); } In this example, you can see how Diffblue Cover: Community Edition creates tests that are actually useful and can even handle more complex scenarios, e.g. mocking. Hopefully this overview gives you an idea of how Community Edition works, but if you have questions or need any help, you can contact us through the Community Forum. Create your free account to unlock your custom reading experience. read original article here
https://coinerblog.com/how-to-start-using-diffblue-cover-community-edition-for-unit-testing-o41931of/
CC-MAIN-2021-04
refinedweb
861
51.58
How to Build a Chat App With Next.js & Firebase In this tutorial, we will guide you through building a simple chat application with Next.js and Firebase. Adding a basic chat feature to your app is an amazing way to connect your users. It allows your users to negotiate, get information, make friends and even fall in love without ever leaving your app. However, modern chat apps don't just display messages. They also show images, have @-mentions, reaction gifs, stickers and all sorts of other features... One of which is the typing indicator. This tutorial will teach you how to add an indicator while a user is typing, adding one more UX improvement to your iOS app and ensuring your users don't escape your app for something more feature complete. Since CometChat already has support for typing notifications in the iOS SDK, all we have to do is build out the UI to our liking! In the process of adding the typing indicator, you'll also learn how to make custom views in iOS, as well as how to make cool-looking animations using Core Animation. By the end of this iOS typing indicator tutorial, this is what you'll end up with: You can find the finished project on GitHub. You'll have a typing indicator that: Pretty cool, right? Let's get started. This tutorial assumes you already have a chat app that you built. Thankfully, we have two tutorials to get you started: Or, you can start by downloading the starting project for this tutorial. Head to the [start-here]() branch of the GitHub repo [TODO: LINK] and clone or download the repo. Open CometChat.xcwrorkspace (not the project file) in Xcode to get started. Setting your app ID Before you can run the app, you'll have to set your CometChat app ID. If you already have a CometChat app, navigate to the CometChat dashboard and click Explore for your app, then click on API Keys in the sidebar.A as the region and enter CometChat as the app's name. Click the + button to create the app. After 15 or so seconds, you'll have an up-and-running chat service online! All you need to do is connect to it. Open your new app's dashboard by clicking Explore. Head over to API Keys in the sidebar. Take a look at the keys with full access scope. %} Now that you're all set, let's get started working on the typing indicator. You'll start working on the typing indicator by creating a new Swift file called, appropriately, TypingIndicatorView.swift. Add the following contents to the file: {% c-block %} import UIKit class TypingIndicatorView: UIView { private enum Constants { static let width: CGFloat = 5 static let scaleDuration: Double = 0.6 static let scaleAmount: Double = 1.6 static let delayBetweenRepeats: Double = 0.9 } } {% c-block-end %} You create a new custom view that will hold your typing indicator. You won't use Interface Builder for this. Instead, you'll do everything in code to make it as flexible as possible. This means you'll have to store a couple of constants, so you create an enum that holds these constants. You'll use them throughout the tutorial. Next, add the following properties and inits to the class: {% c-block %} private let receiverName: String private var stack: UIStackView! init(receiverName: String) { self.receiverName = receiverName super.init(frame: .zero) createView() } required init?(coder: NSCoder) { fatalError() } {% c-block-end %} The receiverName is the name of the person that's typing. The stack is your main stack view where you'll add all of your subviews to build out the typing indicator. To set the receiver name, you'll add a new init that receives the name as a parameter. This init will also call createView – a function you'll create shortly. Since this is a subclass of UIView, there's a required init that has to exist, but it doesn't necessarily need to do anything. So, you'll just fatalError out of it ever gets called. (Don't worry, it won't!) Next, implement the method you called in the initializer: {% c-block %} private func createView() { translatesAutoresizingMaskIntoConstraints = false stack = UIStackView() stack.translatesAutoresizingMaskIntoConstraints = false stack.axis = .horizontal stack.alignment = .center stack.spacing = 5 } {% c-block-end %} This function will build out your whole typing indicator, so this is just its start! First, you set translatesAutoresizingMaskIntoConstraints to false. This mouthful of a property tells UIKit that it shouldn't make any constraints for this view – you'll add those yourself. Next, you create the main stack view. This stack will eventually hold the dots of the ellipsis as well as the text saying "Jane Doe is typing". You make sure it's a horizontal stack and that everything is vertically centered with a bit of spacing between each item. Creating the dot The first view you'll add to the stack will be an unassuming, lonely dot. You'll start by making one, and then copy it two more times to create the ellipsis. Add the following method to the class: {% c-block %} func makeDot(animationDelay: Double) -> UIView { let view = UIView(frame: CGRect( origin: .zero, size: CGSize(width: Constants.width, height: Constants.width))) view.translatesAutoresizingMaskIntoConstraints = false view.widthAnchor.constraint(equalToConstant: Constants.width).isActive = true } {% c-block-end %} First, you create a new view to hold the dot and set its width and height to the one defined in Constants. You also add an Auto Layout constraint to make sure it has a fixed width of the same value. Next, you'll add a circle to the view using Core Animation: {% c-block %} let circle = CAShapeLayer() let path = UIBezierPath( arcCenter: .zero, radius: Constants.width / 2, startAngle: 0, endAngle: 2 * .pi, clockwise: true) circle.path = path.cgPath {% c-block-end %} CAShapeLayers let you draw a custom shape in the screen defined as a Bézier path – a common way to describe paths and shapes as a set of numerical values. You don't have to construct these yourself. Instead, you can use UIBezierPath's initializers to construct different shapes like arcs, lines, ovals, rectangles and any other shape you can think of. In this case, you create a circular path by creating an arc that starts at 0 degrees and rotates around a full circle, ending up at the same spot at 2π, or 360 degrees. You give it a radius equal to the half of the width so that it spans the whole view. You then set that path on the shape layer to draw the circle. Then, add the following lines to the method: {% c-block %} circle.frame = view.bounds circle.fillColor = UIColor.gray.cgColor {% c-block-end %} You set the layer's frame and give the circle a gray fill. Next, add the circle layer to the view and return the view: {% c-line %}view.layer.addSublayer(circle){% c-line-end %} return view This concludes makeDot. At least, for now. Back in createView, add the following code to add a dot to the stack: {% c-block %} let dot = makeDot(animationDelay: 0) stack.addArrangedSubview(dot) addSubview(stack) } {% c-block-end %} Next, you'll add a few constraints to make sure the stack spans the width and height of TypingIndicatorView: {% c-block %} NSLayoutConstraint.activate([ stack.leadingAnchor.constraint(equalTo: leadingAnchor), stack.trailingAnchor.constraint(equalTo: trailingAnchor), stack.topAnchor.constraint(equalTo: topAnchor), stack.bottomAnchor.constraint(equalTo: bottomAnchor) ]) {% c-block-end %} You set the leading, trailing, top and bottom anchor of the stack to all equal the same respective anchors of the view.Speaking of sizing, there's one final thing you need to do to make sure your layout doesn't break. When Auto Layout is laying out your view, it doesn't currently know how wide it should be. Views like UILabel or UIStackView calculate their own size – this size is called the intrinsic content size. You can replicate the same behavior in your views. Add the following override to the class: {% c-block %} override var intrinsicContentSize: CGSize { stack.intrinsicContentSize } {% c-block-end %} This tells Auto Layout how to size your view. In your case, you can return the stack's size since it will always match the while typing indicator view. Now that you built your dot, it's time to show it from the chat screen. Head to ChatViewController.swift and add the following property to the class: {% c-line %}private var typingIndicatorBottomConstraint: NSLayoutConstraint!{% c-line-end %} Later in this tutorial, you'll animate this constraint to show and hide the typing indicator. Next, add this method to the class: {% c-block %} private func createTypingIndicator() { let typingIndicator = TypingIndicatorView(receiverName: receiver.name) view.insertSubview(typingIndicator, belowSubview: textAreaBackground) } {% c-block-end %} This method will set up the typing indicator and add it as a subview. So, in the implementation, you first call TypingIndicatorView's initializer with the receiver's name and add it as a subview below the text area. This is important because the indicator needs to pop up from behind the text field. Next, add the following code to the method: {% c-block %} typingIndicatorBottomConstraint = typingIndicator.bottomAnchor.constraint( equalTo: textAreaBackground.topAnchor, constant: -16) typingIndicatorBottomConstraint.isActive = true {% c-block-end %} Here, you create a constraint to make sure the typing indicator is 16 points from the top of the text field. You'll set the property you created earlier so that you can animate the spacing and hide the typing indicator. Next, add this code to the method to add a couple of additional constraints: {% c-block %} NSLayoutConstraint.activate([ typingIndicator.heightAnchor.constraint(equalToConstant: 20), typingIndicator.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 26) ]) {% c-block-end %} These constraints make sure that the typing indicator's height is 20 and that it has a margin of 26 from the leading edge of the view. Finally, call the method from the bottom of viewDidLoad: {% c-line %}createTypingIndicator(){% c-line-end %} Run your project and enter superhero1 as your email. This is a pre-made test user that CometChat creates for you. Select a contact to chat with and take a look at your dot in all of its glory: Well, it is just a dot, so it might not look that impressive. But, the potential is there! Let's breathe some life into it by making it animate. To make the ellipsis animate you'll animate each dot to scale up and down in the same way. You'll then add a small delay to the second and third dot so that they don't all scale at the same time. That's a pretty neat trick to add the feeling of movement without adding complex animations. [TODO: Screenshot finished animation] Head back to TypingIndicatorView.swift and add the following code to the bottom of makeDot, right before return: {% c-block %} let animation = CABasicAnimation(keyPath: "transform.scale") animation.duration = Constants.scaleDuration / 2 animation.toValue = Constants.scaleAmount animation.isRemovedOnCompletion = false animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) animation.autoreverses = true {% c-block-end %} You might be used to the convenient API of UIView animation, but here's you're working at a lower level: Core Animation layers. To animate these, you'll also have to use a lower-level animation API: CAAnimation. CAAnimations are objects that animate almost anything between a toValue and a fromValue. In your case, you'll animate the scale of the dot, so you supply transform.scale as the key path for the property you want to animate. You then set the toValue to the scale amount from the constants and make sure there's an easing on the animation. By setting autoreverses to true, the layer will automatically reverse the animation so that it scales up and down in the same way. Next, you'll add this animation to an animation group. Add this code to the method: {% c-block %} let animationGroup = CAAnimationGroup() animationGroup.animations = [animation] animationGroup.duration = Constants.scaleDuration + Constants.delayBetweenRepeats animationGroup.repeatCount = .infinity animationGroup.beginTime = CACurrentMediaTime() + animationDelay {% c-block-end %} Usually, animation groups are useful for starting and stopping multiple animations at once. However, in this case, you'll use the group to delay the start of the scaling animation. By giving the group a duration that's longer than the scaling, you ensure a delay between each repeat of the animation. You set the group to repeat infinitely and add another delay to its start time. Finally, add the animation group to the circle layer by adding this line to the method: {% c-line %}circle.add(animationGroup, forKey: "pulse"){% c-line-end %} Run the app and take a look at your circle. Now it looks a bit more impressive: It scales up and down infinitely! Let's turn this dot into an ellipsis by copying it a couple of times. Adding more dots It's time to add some more dots! Still in TypingIndicatorView.swift, add a new method to the class: {% c-block %} private func makeDots() -> UIView { let stack = UIStackView() stack.translatesAutoresizingMaskIntoConstraints = false stack.axis = .horizontal stack.alignment = .bottom stack.spacing = 5 stack.heightAnchor.constraint(equalToConstant: Constants.width).isActive = true } {% c-block-end %} This method creates another stack view which you'll place inside the main stack. This inner stack view will hold all of your dots, so you make it horizontal and align everything to the bottom. You also give it a height equal to the width of one dot. Next, add the following code to the method to add the dots: {% c-block %} let dots = (0..<3).map { i in makeDot(animationDelay: Double(i) * 0.3) } dots.forEach(stack.addArrangedSubview) return stack {% c-block-end %} First, you use map to convert a range of integers (0, 1, 2) to dot views by calling makeDot. Each dot will have a larger delay, starting from zero and increasing by 0.3 seconds with each index. Then, you add the views to the stack by calling addArrangedSubview and, finally, return the stack. Next, inside createView, replace the lines where you create and add dot... {% c-block %} let dot = makeDot(animationDelay: 0) stack.addArrangedSubview(dot) {% c-block-end %} ...with the following two lines: {% c-block %} let dots = makeDots() stack.addArrangedSubview(dots) {% c-block-end %} Build and run the project and take a look. You now have an ellipsis with a neat animation that signals to the user that something is going on. We're still missing the text, so let's get on that! Don't worry, adding the dots was the hard part. Adding the text bit should be smooth sailing. Still in TypingIndicatorView.swift, add a label in createView right under the lines to create and add dots: {% c-block %} let typingIndicatorLabel = UILabel() typingIndicatorLabel.translatesAutoresizingMaskIntoConstraints = false stack.addArrangedSubview(typingIndicatorLabel) {% c-block-end %} You create a label, remove default constraints and add it to the main stack view. Next, add some text to the label: {% c-block %} let attributedString = NSMutableAttributedString( string: receiverName, attributes: [.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)]) {% c-block-end %} {% c-block %} let isTypingString = NSAttributedString( string: " is typing", attributes: [.font: UIFont.systemFont(ofSize: UIFont.systemFontSize)]) {% c-block-end %} {% c-block %} attributedString.append(isTypingString) typingIndicatorLabel.attributedText = attributedString {% c-block-end %} Instead of using plain strings, you use an attributed string to bold part of the text. Specifically, the username will be bold, so you create the username part of the text by adding an attribute to make the font bold. This bit of text is a mutable string. Next, you create an immutable attributed string with the rest of the text and a regular, non-bold font. You then append the non-bold part to the mutable string, like you were concatenating two regular strings. The result is that attributedString now holds a bold username and regular text saying "is typing". Run the project to take a look. Now the user can see who's typing. The typing indicator looks nice, but there's a little problem. It's always there! In the rest of this iOS typing indicator tutorial, you'll show and hide the indicator with an animation based on whether the user is typing or not. First, let's add an animation for when the indicator pops up and down. Open ChatViewController.swift and add a new method to the class: {% c-block language="swift" %} private func setTypingIndicatorVisible(_ isVisible: Bool) { let constant: CGFloat = isVisible ? -16 : 16 UIView.animate(withDuration: 0.4, delay: 0, options: .curveEaseInOut, animations: { self.typingIndicatorBottomConstraint.constant = constant self.view.layoutIfNeeded() }) } {% c-block-end %} Remember the constraint you declared earlier that determines the spacing between the text field and the typing indicator? Here, you'll toggle its constant between -16, when it's raised, and 16, when it should be hidden. Because the text field is on top of the typing indicator (in the z-axis), you won't see it if the constraint is set to 16. Next, in createTypingIndicator, locate the line where you set typingIndicatorBottomConstraint and change its constant to 16 instead of -16: {% c-block %} typingIndicatorBottomConstraint = typingIndicator.bottomAnchor.constraint( equalTo: textAreaBackground.topAnchor, // Change this line: constant: 16) {% c-block-end %} This ensures the typing indicator is hidden when the view loads. Then, test out the hiding and showing animation by temporarily adding the following two lines at the top of sendMessage: {% c-line %} setTypingIndicatorVisible(typingIndicatorBottomConstraint.constant == 16) {% c-line-end %} return This will toggle the typing indicator whenever you press the send button. Run the project to try it. Press the send button a couple of times and you should see the typing indicator pop up and down. Looking good! Remove the two lines you just added. You won't be needing them anymore, because you'll track the actual typing state. Thankfully, CometChat makes it easy to track when someone is typing. If you followed our previous iOS chat app tutorials, this approach will be familiar to you. Open ChatService.swift and add the following two closures to the top of the class: var onTypingStarted: ((User)-> Void)? var onTypingEnded: ((User)-> Void)? ChatService will call these functions whenever a user starts or stops typing. Next, add the following method to the class: {% c-block language="swift" %} func startTyping(to receiver: User) { let typingIndicator = TypingIndicator(receiverID: receiver.id, receiverType: .user) CometChat.startTyping(indicator: typingIndicator) } {% c-block-end %} You'll call this method when a user starts typing. It creates a new TypingIndicator object that holds information about the typing that's going on. It then uses that object to tell CometChat that typing has begun. Add another, very similar method below the one you just added: {% c-block language="swift" %} func stopTyping(to receiver: User) { let typingIndicator = TypingIndicator(receiverID: receiver.id, receiverType: .user) CometChat.endTyping(indicator: typingIndicator) } {% c-block-end %} This method is analogous to the previous one, only this one stops the typing. Then, you'll implement delegate methods to track when another user is typing. Add a new method inside the CometChatUserDelegate extension at the bottom of the file: {% c-block language="swift" %} func onTypingStarted(_ typingDetails: TypingIndicator) { guard let cometChatUser = typingDetails.sender else { return } DispatchQueue.main.async { self.onTypingStarted?(User(cometChatUser)) } } {% c-block-end %} CometChat calls this method when typing begins for a user. First, you'll grab the user and then switch to the main queue. From there, you'll call the closure you declared earlier, but not before you convert the user to your own User struct. Finally, add another delegate method below the previous one: {% c-block language="swift" %} func onTypingEnded(_ typingDetails: TypingIndicator) { guard let cometChatUser = typingDetails.sender else { return } DispatchQueue.main.async { self.onTypingEnded?(User(cometChatUser)) } } {% c-block-end %} This method is almost the same, except it gets called when a user stops typing, and calls the appropriate closure for when typing stops. That's all we need to do in ChatService. Let's move to the view controller to hook everything up. Open ChatViewController.swift and start by adding the following code to the bottom of viewDidLoad: {% c-block language="swift" %} ChatService.shared.onTypingStarted = { [weak self] user in if user.id == self?.receiver.id { self?.setTypingIndicatorVisible(true) } } ChatService.shared.onTypingEnded = { [weak self] user in if user.id == self?.receiver.id { self?.setTypingIndicatorVisible(false) } } {% c-block-end %} Here, you assign the two closures you created earlier. When a user starts typing, you'll check that the user is your receiver. If they are, you'll show the typing indicator. This is necessary because the typing closure could be called for a different contact that's not open in this view controller. Similarly, if you get notified that the receiver stopped typing, you'll hide the typing indicator. Next, you'll need to check if the current user is typing and send that information to CometChat. Scroll down to the UITextViewDelegate extension and add a new method to the extension: {% c-block %} // 1 func textView( _ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { // 2 let currentText: String = textView.text let range = Range(range, in: currentText)! let newText = currentText.replacingCharacters(in: range, with: text) // 3 switch (currentText.isEmpty, newText.isEmpty) { // 4 case (true, false): ChatService.shared.startTyping(to: receiver) // 5 case (false, true): ChatService.shared.stopTyping(to: receiver) default: break } // 6 return true } {% c-block-end %} This method looks jam-packed with information, so let's take it step-by-step: Now you're sending the typing state to CometChat! There's one final line of code you need to add. Scroll up to sendMessage, and add this line right before the call to ChatService.shared.send: ChatService.shared.stopTyping(to: receiver) This makes sure to reset the typing state when your user sends a message. Run the project on two devices (or two simulator instances). On one device, log in as superhero1 and start chatting with Captain America. On the other device, log in as superhero2 and start chatting with Iron Man. As you start typing, you should see a typing indicator pop up on the other device! You can find the finished project on GitHub. Using a combination of CometChat, UIView animation, Core Animation and your chops, you made a nice looking animated typing indicator! It animates into view, has a pulsing ellipsis animation and shows the username of the person that's typing. Armed with this knowledge, you can go even further and explore other ways to improve your UX: If you want a more detailed look at how to build a chat app with CometChat, take a look at the iOS one-on-one chat app tutorial or the iOS group chat app tutorial. If you're ahead of the curve and want to build a SwiftUI chat app, you can go through our SwiftUI course on building a chat app in SwiftUI. I hope this iOS typing indicator tutorial helped give your users a better chat experience!
https://www.cometchat.com/tutorials/add-an-animated-typing-indicator-to-your-ios-chat-app
CC-MAIN-2021-43
refinedweb
3,780
57.67
>>:: ... Simple User Interfaces with easygui [ID:245] . easygui is a great module for building simple user-interfaces, created by Stephen Ferg, built on top of Tkinter. Here we learn how to create a file-open box in just 1 line of code, so we can easily open any .csv file. Tkinter is the cross-platform GUI module that is distributed with Python, but it has a learning-curve. easygui takes away the learning curve by providing a set of simple commands that let us build simple user-interfaces in just a few lines of code. Task: Download easygui.py from ferg.org, look at the documentation and the python file Created May 2007, running time 8 minutes. - python - beginners - tutorials - beginner_programming - code - time - running - graphics - application - files - make - screencasts - create - learn - development - user - work - look - GUI - builds - IDE - open - useful - learning - commands - modules - download - programmers - set - good - read - building - interfaces - values - debugging - wing - problem - nosetests - messages - cross-platform - wingware - complete - easygui - keep - fully-worked - csv - tasks - documentation - reviews Got any questions? Get answers in the ShowMeDo Learners Google Group. Video statistics: - Video's rank shown in the most popular listing - Video plays:'m running OS X. The easygui file dialog box dims all the files and doesn't allow me to choose one. Very useful module. Thanks for the video. Good one. Simple User Interfaces with easygui (4/17) 1:00 from easygui import 1:29 EasyGui videos 2:00 EasyGui instruction guide 2:54 sys.exit() 3:40 demo of open dialog (fileopenbox) 4:30 #sys.exit() 5:00 test with different CSV file 5:20 demo run at command line 5:54 other development environment errors (WING) Resources: Gre8 video, everything is working so far. Thanks. Very helpful. I am wanting to create a simple data viewer that requires opening csv files, doing some simple processing and generating some plots. (Obviously easygui isn't going to do the plots but having a simple way of navigating to the appropriate file and opening it into a csv object is very helpful. Ian, you kick ass :) Damn ole Tkinter is a bothersome bugger on debug time under Wing :) well done, great Its all so easy when u explain these things! much better than diving alone through thousands of pages Do you have something for txt. file formatting and processing? Hi Balek, sorry about that, the video is back - we had a glitch with the db. Ian. Your video has been edited. This is an automatic post by ShowMeDo. This video seems to be missing currently. I would love to see it. :) Your video has been edited. This is an automatic post by ShowMeDo. This is a great video, and seeing linking to Horst's videos was genius. Seeing those you guys using python with such ease is inspiring. I'm using Ubuntu and SPE (Stani's Python Editor) and had no issues at all whilst working through this. Cool, whilst we've had requests for pyQT I've not used it myself. Thanks for sharing your code, it looks really easy to try. Ian. Very nice. I actually like QT4 from trolltech, so I experimented and looked around a bit. and found I could do the same in PyQt4. My code looks like this: import csv from PyQt4 import QtGui app = QtGui.QApplication([]) # Need to create an Application fileAndPath = QtGui.QFileDialog().getOpenFileName() # Show a File Open Dialog. print "Using:",fileAndPath reader = csv.reader(open(fileAndPath, "rb")) for row in reader: print row Hi Marlow. Yes, the q&a is difficult here as our system doesn't really facilitate it. The old forum did - but that was hidden in another system so people didn't often find it. The new Learners google group () is specifically aimed at people just like you who have questions, where asking it publicly might yield several sets of interesting answers. Do feel free to post in the Group to help get things started. Cheers, Ian. Yes, I agree that putting easygui into \Lib wasn't the best choice--because I'd like to have some easy way to maintain a standard system on other pc's. And when I update python versions the last thing I need is misc utilities & modules I've scattered in the system code! I'm just not familiar with the conventions yet. So thanks for the suggestion: I've moved it to \python25\site-packages That does seem to be where the extras you've introduced me to have installed themselves--so hopefully I'll remember to look there when updating or reproducing my setup to e.g. the laptop. Posting q&as here in a lesson is somewhat awkward as I have to remember to which episode I've posted a question, etc. I added the rss feed to my home page, but the messages roll off fast enough that that doesn't help. The showmedo forums-which I guess didn't take off-would seem to be the easiest location--mainly because one is already in showmedo if you're working on some lessons. A google groups would be fine--if people use it. When I started lessons I looked at the showmedo group and most of the traffic was re. screencasting technology & business etc. A more active user/newbie community would certainly mean we could answer simple questions among ourselves and leave the real brain teasers to you gurus! ;-) Ha, not trying to kiss up too much, but I do appreciate your helpful answers! Thanks also for the pointers to other python communities where help & disc of beginner issues is available. One difficulty with maintaining an active user/newbie forum here must be that after a while folks either grow out of newbiedom or give up. (I'm sure you observe a tutorial use lifecycle. I suppose you've got to keep cranking out interesting episodes to keep us hooked!) I'm already feeling more comfortable with the Guido's python tutorial book & looking stuff up. I appreciate the nice way your lessons periodically nudge viewers into looking things up, directing them where & how to answer their own questions to solve problems. It all helps make us more independent which is the goal all along. Hi Marlow. 1) Easygui probably belongs in \python25\site-packages rather than in Lib. Normally all extra modules are put into site-packages or a subdirectory inside there, I'll guess that PyDev is looking there rather than in \Lib. You don't have to register anything, Python just searches the normal paths (e.g. site-packages). 2) If it is unused then fair-enough! I didn't know that pydev reports that, that's rather cool. 3) It is great that you've found a good place to post your questions :-) This is *exactly* why I have just (today) started a new Google Group called 'ShowMeDo Learners': which will be aimed at all ShowMeDo users to discuss learning the topics that we carry. It will be especially useful to Subscribers who are all going through the same process with Python at the same time. I strongly urge you to join the Group, I'll be announcing it to everyone over the next week. You might also want to check the official Python Tutor list which is very active: and PyDev has its own forum: Cheers, Ian. Nice episode Ian, I used Pydev which worked fine. No problems with the graphics, etc. although Eclipse/Pydev remains somewhat mysterious to me (still wonder about how to control the panels/windows....e.g. there's a problems window with errors remaining from an earlier .py file which I've long since closed. Seems odd I cannot clear the errors without restarting Eclipse or something.) A couple questions: 1. I put easygui.py into my f:\Python25\Lib\ directory--didn't want to put it into my application dir as you did since I'd like to use easygui in other projects. Python found easygui.py fine & created the .pyc file just fine. However, pydev continues to report an error "unresolved import" on the import easygui line in my source code. Even though the little program works without error when called either from cmd or from within pydev. This is a mystery to me--when pydev is installed does it read & somehow "register?" files in \Python25\Lib\ ? 2. pydev also reports ...Unused import: sys Possibly the 'open("..' you used earlier required sys? I don't know, but anyway the pydev was correct on this one since I comment out the import sys and things work just fine. I presume this is because easygui.py contains 'import sys' itself. 3. I post these comments here as I haven't found an active community in google groups. Anyway, thanks for introducing easygui. I'd never heard of it & one of the reasons I had delayed getting into python is cause I'd been somewhat glum that I'd have to learn lots of Tkinter or wxpython or something else & learn the difference between them, etc. just to begin writing the slightest useful scripts. However, easygui fills this need nicely & is just what one needs for writing quick scripts--what I intend before moving on to anything big. Kudos to Stephen Ferg . This sort of community contribution tool is some of the longer run reason I'm wanting to spend time learning python rather than a newer version of visual studio. I would like to see a 'howto' read the library reference in python so we dont get a specific knowledge of a library and isntead a knowledge on how to use any library. many python library have auto-generated documentation (kind of like javadocs). However I can hardly follow it through. I would love to see a video on this subject. Easy to follow and very references. Fantastic. Now we are getting somewhere. I work on data analysis all the time and am always working on work-arounds - Python with CSV and easygui look perfect for the work that I do in GIS - great job on explaining it. great video. I like the fact that the program is simple to start with experimentation. Hi dexy. Look for the 'Download 910030.flv' link under the video, of course you have to have purchased the series to download it first. Ian. Great videos.How can i download the videao Great stuff :-) As I say in the video I had a similar reaction when I first learned about easygui from Horst's videos, and they were in German at the time! easygui really is very nice, I'm enjoying writing a few blog articles (blog.showmedo.com) about it at the moment. Ian. I really enjoyed this video. In my spare time I have actually been playing around with wxPython and have been looking to alternatives (Tkinter was one) and didn't even think to use easygui. Looks like I'm going to have to watch the other easygui videos you referenced in the tutorial. This looks so much easier and your tutorial is very clear on how to use easygui to open a File-Open dialog and save the file selection for use later in your program. Thumbs Up!! Great! Thanks for letting us know that it works on different platforms, so good to know! Your videos are worth quoting from - they're great introductions (and the kids are just darn good at their presentations). Ian. hehe, i think this is my all-time-favorite video...thanks for quoting my videos.. *bows*. about easygui and linux: i used easygui on debian and ubuntu platforms from the python prompt , from Idle and from DrPython (wich is written in wxpython) and it always worked.
http://showmedo.com/videotutorials/video?name=910030&allcomments=1
CC-MAIN-2016-30
refinedweb
1,952
73.37
wmemmove (3p) - Linux Man Pages wmemmove: copy wide characters in memory with overlapping areas PROLOGThis manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME wmemmove - copy wide characters in memory with overlapping areas SYNOPSIS #include <wchar.h> wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n); DESCRIPTION The wmemmove() function shall copy n wide characters from the object pointed to by ws2 to the object pointed to by ws1. Copying shall take shall not be affected by locale and all wchar_t values shall be treated identically. The null wide character and wchar_t values not corresponding to valid characters shall not be treated specially. If n is zero, the application shall ensure that ws1 and ws2 are valid pointers, and the function shall copy zero wide characters. RETURN VALUE The wmemmove() function shall return the value of ws1. .
https://www.systutorials.com/docs/linux/man/3p-wmemmove/
CC-MAIN-2021-21
refinedweb
167
50.67
On Tue, Mar 06, 2018 at 12:16:08PM +0800, Haozhong Zhang wrote: > On 03/02/18 12:03 +0000, Anthony PERARD wrote: > > On Wed, Feb 28, 2018 at 05:36:59PM +0800, Haozhong Zhang wrote: > > > On 02/27/18 17:22 +0000, Anthony PERARD wrote: > > > > On Thu, Dec 07, 2017 at 06:18:02PM +0800, Haozhong Zhang wrote: > > > > > This is the QEMU part patches that works with the associated Xen > > > > > patches to enable vNVDIMM support for Xen HVM domains. Xen relies on > > > > > QEMU to build guest NFIT and NVDIMM namespace devices, and allocate > > > > > guest address space for vNVDIMM devices. > > > > > > > > I've got other question, and maybe possible improvements. > > > > > > > > When QEMU build the ACPI tables, it also initialize some MemoryRegion, > > > > which use more guest memory. Do you know if those regions are used with > > > > your patch series on Xen? > > > > > > Yes, that's why dm_acpi_size is introduced. > > > > > > > Otherwise, we could try to avoid their > > > > creation with this: > > > > In xenfv_machine_options() > > > > m->rom_file_has_mr = false; > > > > (setting this in xen_hvm_init() would probably be better, but I havn't > > > > try) > > > > > > If my memory is correct, simply setting rom_file_has_mr to false does > > > not work (though I cannot remind the exact reason). I'll have a look > > > as the code to refresh my memory. > > > > I've played a bit with this idea, but without a proper NVDIMM available > > for the guest, so I don't know if it's going to work properly without > > the mr. > > > > To make it work, I had to disable some code in acpi_build_update() that > > make use of the MemoryRegions, as well as an assert in acpi_setup(). > > After those small hacks, I could boot the guest, and I've check that the > > expected ACPI tables where there, and they looked correct to my eyes. > > And least `ndctl list` works and showed the nvdimm (that I have > > configured on QEMU's cmdline). > > > > But I may not have been far enough with my tests, and maybe something > > later relies on the MRs, especially the _DSM method that I don't know if > > it was working properly. > > > > Anyway, that why I proposed the idea, and if we can avoid more > > uncertainty about how much guest memory QEMU is going to use, that would > > be good. > > > > Yes, I also tested some non-trivial _DSM methods and it looks rom > files without memory regions can work with Xen after some > modifications. I'll apply this idea in the next version if no other > issues are found. Advertising Awesome, thanks. -- Anthony PERARD
https://www.mail-archive.com/qemu-devel@nongnu.org/msg519102.html
CC-MAIN-2018-13
refinedweb
412
65.25
How to Setup a React App from Scratch? Aman Mittal— November 16, 2017 Note: This is article is written for demonstration purposes. Not ready for 🚀. When learning React a developer can feel blessed with so many boilerplate/starter-kits out there such that they let the learner focus on more on the fundamentals of React API rather than setting up a project from scratch. However, IMO one should create a react app with bare minimals or scratch that, just for the sake of learning tools. Tools do help you. They are similar that are being used in various starter-kits but if you have no knowledge of these tools, how are you going to scale an application or tweak configuration according to your own settings? These tools I am talking about are common and essential for React Application development. In this project, I am going to build a bare minimal React app, let’s a hello world example but I will be focusing more on tooling and other essentials when building a React application. Pre-Requisites Before reading rest of the document, I am assume you are familiar with: - Git - Node.js (installed) - npm - What web apps are? - What is React? (just the introduction) - Modern JavaScript (not necesary but good for if you decided to play with React for the rest of your weekend) To fill the gaps, I highly recommend you take a glimpse of React Express. Step 1: Initial Setup Make sure you are inside a directory where you want to build your react app. mkdir react-app-example && cd $_ Then run npm init or yarn init. I am sticking with npm. Also, my current npm version is: npm -v5.5.1 Do make sure you are using Node.js version >= 6. This is the directory structure I have for my initial setup: I will start by taking a look into each file mentioned above in the directory structure of our application. .gitignore This file prevents uploading OS generated files such as (.DS_Store), node_modules folder and other things that you don’t want to commit to your VSC such as Github. package.json Next I am going to update my package.json and other meta information that you'd want before deploying or committing on a VCS. This file is the only result of following command from terminal: npm init --yes Currently, the file looks like below but it will get updates as soon as we pass the initial setup step. {"name": "react-app-bootsrapping","version": "0.1.0","description": "How to Build a React from Scratch?","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1"},"keywords": [],"author": "Your Name <you email> ()","license": "MIT"} Step 2: ESLint & Prettier Create .eslintrc & eslintignore. # installing eslint essential packages for development (as DevDependencies)npm install -D eslint@3.19.0 eslint-config-airbnb@15.0.1 eslint-config-react eslint-loader eslint-plugin-import eslint-plugin-jsx-a11y@5.0.3 eslint-plugin-react Prettier Next I’ll recommend to use Prettier. This will save a lot of time formatting code. It might be opinionated but it is good sometimes to have an opinion that benefit all of us. To setup prettier for your project, you need: npm i -D prettier eslint-config-prettier eslint-plugin-prettier The .eslintrc configuration now should be like this: {"extends": ["airbnb", "prettier", "prettier/react"],"plugins": ["prettier"],"parser": "babel-eslint","parserOptions": {"ecmaVersion": 2016,"sourceType": "module","ecmaFeatures": {"jsx": true}},"env": {"es6": true,"browser": true,"node": true}} To run lint our files manually later on, we can add an npm script in our package.json under "scripts": "scripts": {"lint": "eslint **/*.{js,jsx} --quiet"} Step 3: Configuring Babel In short: Babel is a transpiler/compiler that compiles ES6 code to ES5 for most of the browsers to understand. Essential packages to setup Babel in our project: npm i -D babel-core babel-eslint babel-loader babel-plugin-dynamic-import-node babel-plugin-syntax-dynamic-import babel-plugin-transform-class-properties babel-plugin-transform-es2015-modules-commonjs babel-preset-env babel-preset-react# after above commmand runs successfulynpm i -S babel-plugin-dynamic-import-webpack babel-plugin-transform-decorators-legacy Next, configure .babelrc: {"presets": ["react",["env",{"targets": {"browsers": "last 2 versions"},"loose": true,"modules": false}]],"plugins": ["babel-plugin-transform-class-properties"],"env": {"test": {"plugins": ["babel-plugin-transform-es2015-modules-commonjs"]}}} Following along so far? If having any trouble, do check this code repository on Github. Step 4: Configure Webpack First let’s install essential packages: npm i -S webpack Now append webpack.config.js: const path = require('path')module.exports = {context: __dirname,entry: './src/App.jsx',devtool: 'cheap-eval-source-map',output: {path: path.join(__dirname, 'public'),filename: 'bundle.js'},resolve: {extensions: ['.js', '.jsx', '.json']},stats: {colors: true,reasons: true,chunks: true},module: {rules: [{test: /\.jsx?$/,loader: 'babel-loader'}]}} And do not forget to append npm scripts with two new scripts build and watch: "scripts": {"build": "webpack","lint": "eslint **/*.{js,jsx} --quiet","watch": "webpack --watch"} Step 5: .editorconfig & .eslintignore This file enforces code formatting rules on most editors for consistency. For more information visit here. # editorconfig.orgroot = true[*]indent_style = tabindent_size = 2end_of_line = lfcharset = utf-8insert_final_newline = truetrim_trailing_whitespace = true One more thing I forgot to mention in Step 2 is to add rules to .eslintignore such that we can exclude bundle.js which is a result of webpack bundling and node_modules. public/node_modules/ Step 7: Adding React and ReactDOM To test our bare minimum configuration we are going to setup a timy react application to see if everyting works. First I’d recommend to create two new directories in root of your project: public (where index.html lies as well as the outpt generated from webpack configuration )and src (where we wil write out tiny app code). # install minimum required packages to instatiate a react applicationnpm i -S react react-dom Please note that I am using react@ 15.6.1 version. I do not want to break things for any hassle and I am sure neither do you. To make sure you have this application working, I'd recommend you to run following command instead of above: npm i -S react@15.6.1 react-dom@15.6.1 Now make sure your public/index.html is similar to this: <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><title>React App</title></head><body><div id="app"></div><script src="bundle.js"></script></body></html> Inside src/App.jsx write the following code: import React from 'react'import { render } from 'react-dom'const App = () => (<div><h1>Hello World</h1><p>This is a Reactjs application</p></div>)render(<App />, document.getElementById('app')) Now run from terminal: npm run build This command will generate public/bundle.js that will act as the single source of truth for all of your JavaScript. Now traverse to your project directory in a file manager and open index.html in your browser. You will see a similar output depending on the input you wrote inside App.jsx file. Note: Many starter-kits follow conventions of .js instead of .jsx. I wanted to demonstrate that you can use both and as per my knowledge, since we are following AirBnB configuration, they follow .jsx file naming convention. On running npm run build you can see the following success message in your terminal. Any error(s) while packaging, webpack will highlight them in red colour. Great! You have just created your first Hello World React App with good amount of configuration. If you want to play further with your react app, I’d recommend using npm run watch instead of build since the former command will watch for any changes made. Step 8: Linting Your Code If you have followed along and done exactly what is written, you will see no errors on running npm run lint in your terminal. However, this is a tedious process to run for linting every time you make amendments in your code base. I highly recommend, to configure your eslint with the webpack configuration just by adding this rule in webpack.config.js: module: {rules: [// new rule we are adding right now{enforce: 'pre',test: /\.jsx?$/,loader: 'eslint-loader',exclude: '/node_modules/'},// rule we added earlier{test: /\.jsx?$/,loader: 'babel-loader'}]} Now run npm run watch for Webpack to watch for file changes and linting will be done along with that. To see that action, let's make a change to our App.jsx file. Make sure, your currently running the watch command and your output is initial webpack output. To make a distinction between the new output, see my terminal: Now I am going to break my code just for linting errors: <h1>Hello, World</h1>// linting error in the line below<h2>This is sub header<p>This is a Reactjs application</p></div>; My terminal now looks like this: Until you do not solve this error, the output will not be shown in the browser. Now that you understand or have an idea of what steps are covered by a React Starter Kit I think you are ready to pick your favorite kit and start developing your next React app. I have demonstrated only bare minimum configuration of tools such as Babel, ESLint and Webpack. There are things like Hot Module Reloading(HMR) and Webpack Dev Server that saves a good amount of developer’s time period. Also, do not forget the deployment part. That’s the last and most essential part in the lifecycle of a web application. Below I am listing resources that will help you go in-depth of tools such as webpack and some starter-kits. Some React Starter Kits worth looking at: Different kits cover different scope for applications. If you want to share any React resource that you think will be useful for someone like me who is getting started in the React Development Ecosystem, please mention it in the comment below. You can find all of the above over this Github repo. Originally Published at codeburst.io
https://amanhimself.dev/how-to-setup-a-react-app-from-scratch/
CC-MAIN-2020-10
refinedweb
1,667
56.25
It seams for now pybar is the solution which is easier to get results with. But one day if the fem wb is ready to use even with beams an shells we are capable of calculating everything what we could model directly from CAD. bernd It actually is very cool. Works even for double T crosssectionsIt actually is very cool. Works even for double T crosssectionsrockn wrote:Look very cool !... yorik wrote:Yes, we could upgrade the system... It could even be pretty simple, use the same Nodes property, since we only need 2 vectors to define a plane. Then, depending on the role of the element, we show a line/polyline or a plane. ... I had a try on this. The code use simplest integration, so not very accurate. Also it would be better to go through every edge and discretize it instead of discretize the wire.I had a try on this. The code use simplest integration, so not very accurate. Also it would be better to go through every edge and discretize it instead of discretize the wire.A little question that annoys me, the pybar files needs the quadratic moments from the sections of the structural members. Code: Select all import Part def Moment_2(sketch): # 1 get inner and outer wire wires = sketch.Shape.Wires # check boundingbox diagonals to get outer shape diagonals = [wire.BoundBox.DiagonalLength for wire in wires] pos = diagonals.index(max(diagonals)) # reordering outer_wire = wires[pos] wires.pop(pos) wires.insert(0, outer_wire) Ix = 0 Iy = 0 for j, wire in enumerate(wires): pts = wire.discretize(1000) ix = 0 iy = 0 for i, pt in enumerate(pts[:-1]): # one point integration midpoint = (pts[i] + pts[i + 1]) * 0.5 diff = pts[i] - pts[i + 1] ix += midpoint.y ** 3 * diff.x / 3. iy += midpoint.x ** 3 * diff.y / 3. Ix += ((j == 0)*2 - 1) * abs(ix) Iy += ((j == 0)*2 - 1) * abs(iy) return(Ix, Iy) a = App.ActiveDocument.Sketch print(Moment_2(a))
https://forum.freecadweb.org/viewtopic.php?p=40571
CC-MAIN-2019-43
refinedweb
330
68.16
Introduction I was recently working in the CODESYS runtime again, developing some components for a client and I thought the experience wold make the basis of a good post on bringing legacy code into a test environment, to enable Test Driven Development (TDD) The CODESYS runtime is a component based system, and for most device manufacturers is delivered as a binary for their target system and a collection of header files and interface definitions. Much of the interface is generic, however there are platform specific headers that abstract the underlying RTOS. Device manufacturers often develop bespoke runtime components, to access proprietary IO for example. To help with this the delivered software package includes template components as a starting point for development. This means that, according to Michael Feathers definition of legacy code (code without tests), the starting point when developing a CODESYS component is legacy code. In this example the starting point was a partially developed component, legacy code. The Plan I tend to follow a fairly standard process when bringing legacy code under test. The basic process is well described in TDD How-to: Get your legacy C into a test harness on James Grenning’s blog. I follow roughly the same process, with minor changes, my process can be summarised as follows - Select appropriate tools - Create a test harness with no reference to the code to be tested and a dummy failing test. Observe it fail. Fix the test and observe it pass. - Decide the boundaries of the code I want to test, and include this source in the test harness build. - Make the test harness compile (not link) - Make the code Link using exploding fakes. - Ensure the dummy test still passes - Add the first test of the code under test (expect it to crash or fail) - Make the test pass by adding initialisation, and using better fakes. - Add more tests, always observe them fail (force a failure if needs be – to check that the error output is meaningful), factor out common code into helper functions. Keep the tests small and testing one thing. - Add profiling, I like to be able to observe which parts of the code are under test before I make any changes. Particularly if the code under test has large complex functions it is the only way that I trust I have sufficient coverage before making code changes. Tools The development build of the component uses a gcc cross compiler on linux. The build is controlled by a makefile and there is already an eclipse project. I will use the native gcc compiler to run the tests For the testing framework I’m using googletest 1.8, my preferred test framework for C and C++ To help with creating fakes and mocks I will use Mike Long’s Fake Function Framework (fff). I will add plugins to eclipse so that the whole process can happen in a single environment. The first test There are two ways of using googletest, one is to build it as a library and link it to the tests, the other is to fuse the source into a single file, and then include the fused source in the tests. On linux I tend to just build the library with default settings. I’ve created a new folder called UnitTests to which I’ve added a makefile and a single source file with this content #include "gtest/gtest.h" namespace { TEST(FirstTest, ShouldPass) { ASSERT_EQ(1,0); } } // namespace The makefile, references just this source file, the include path has the path to googletest/include. The link line is shown below (I’ve omitted the paths for simplicity) g++ FirstTest.o gtest_main.a -lpthread -o UnitTest This builds, and when run fails as below Change the the ASSERT_EQ so that the test passes, rebuild and re-run the tests. Compiling with the UUT The CODESYS component that that I’m working on consists of a single source file (The Unit Under Test UUT), and it links into a target specific library To get the test application to compile I had to add three directories to the include path -I$(CODESYS)/Components -I$(CODESYS)/Platforms/Linux -I$(TARGET_LIB_SRC)/include NOTE: If the CODESYS runtime delivery is for a different operating system to the development system then it may be necessary to create fake versions of the headers in the Platforms directory. It may also be necessary to fake some of the RTOS header files. Linking – Exploding Fakes Having resolved the includes there are lots of unresolved symbols. A good starting point is to generate a file of exploding fakes, the idea here is to ensure that you know when you are faking code. Have a look at James’ exploding fake generator, this can easily be adapted to any linker and any test framework. Save the output of your failed link into a file, execute gen-exploding-fakes-from-linker-output.sh to generate a file of exploding fakes which you include into your build. make >& make.out gen-exploding-fakes-from-linker-output.sh make.out explodingfake.c The only other change required is to copy explodingfakes.h somewhere on the include path for the tests and adapt it to work with gtest as shown. #ifndef EXPLODING_FAKE_INCLUDED #define EXPLODING_FAKE_INCLUDED #include "gtest/gtest.h" #define EXPLODING_FAKE_FOR(f) void f() { FAIL() << "go write a proper stub for " #f; } #endif Now the test application should run and pass again, none of the UUT is yet being executed. Testing – Part 1 CODESYS components have well defined interfaces, and I find it pays to test from those interfaces rather then exposing internals of the component wherever possible. Taking this approach tends to lead to less fragile tests that are testing the functionality rather than the implementation. All components implement CmpItf, an interface that allows the component to be registered and initialised. CmpItf requires a single extern function ComponentEntry to be declared, all other functions in the interface are accessed through function pointers returned by this function call. So my starting point is to write tests that test this interface. The first tests are straight forward, and soon the ComponentEntry call itself is factored out into the test constructor. #include "gtest/gtest.h" extern "C" { #include "CmpMyComponentDep.h" DLL_DECL RTS_INT CDECL ComponentEntry(INIT_STRUCT *pInitStruct); } namespace { class CmpItfTest: public ::testing::Test { public: CmpItfTest():m_rResult(ERR_OK),m_InitStruct() { m_rResult = ComponentEntry(&m_InitStruct); } RTS_RESULT m_rResult; INIT_STRUCT m_InitStruct; }; TEST_F(CmpItfTest, ComponentEntryShouldSucceed) { ASSERT_EQ(ERR_OK, m_rResult); } TEST_F(CmpItfTest, ComponentEntryShouldSetComponentID) { ASSERT_EQ(0x166B2002, m_InitStruct.CmpId); } TEST_F(CmpItfTest, CmpGetVersionShouldReturnCorrectVersion) { ASSERT_EQ(0x03050800, m_InitStruct.pfGetVersion()); } Fairly soon I am testing code that calls into other CODESYS components, as soon as I do, the exploding fakes show up in the tests. Using The Fake Function Framework Now I need a more powerful fake, this is where the fake function framework comes in to it’s own. Creating a fake for EventOpen can be as simple as adding the following to the test source file, and making sure fff.h is on the include path #include "fff.h" #include "CmpEventMgrItf.h" DEFINE_FFF_GLOBALS; FAKE_VALUE_FUNC( RTS_HANDLE, EventOpen , EVENTID , CMPID , RTS_RESULT *); Having added this the link will fail with a message like CmpEventMgrItf.fff.c:7: multiple definition of `EventOpen' Remove the line from explodingfakes.c for EventOpen, and the tests should now run again. It is then possible to write a simple test to prove that the EventOpen function has been called. TEST_F(CmpItfTest, HookCH_INIT3ShouldOpenEvent) { m_InitStruct.pfHookFunction(CH_INIT3,0,0); ASSERT_EQ(1, EventOpen_fake.call_count); } The Fake Function Framework includes facilities for recording a history of argument calls, setting return values and the ability to provide a custom fake. It makes a very powerful tool for testing C code, I’m not going to cover all of the features here there are plenty of other examples on the web. Do note though that fakes need to be reset for each new test. The constructor for my test fixture looks like this CmpItfTest():m_rResult(ERR_OK),m_InitStruct() { m_rResult = ComponentEntry(&m_InitStruct); RESET_FAKE(EventOpen); FFF_RESET_HISTORY(); } As tests grow and there become multiple test files using the same fakes it makes sense to pull the fakes out into separate files,. I follow a pattern, if I am faking functions defined in a file called XXX.h, I create XXX.fff.h and XXX.fff.c and define my fakes in these files. Most of the time I take the approach of generating each fake manually, one by one as required. CODESYS specifies the interface to all components in .m4 files, in the delivery I have there are 164 interface files specified. I know that over time these interfaces will be extended, and more interfaces added. I have generated a tool to process the interface definitions and automatically generate fff fakes for each API function in each of the interfaces. I then build these fakes into a static library that can be linked with any component I develop. There is a danger in automating fake generation, it becomes very easy to not realise when you are using a fake. Most API functions in CODESYS return an RTS_RESULT, ERR_OK means success. ERR_OK has the value of zero which is also the default value returned by fff fakes. If developing new code this isn’t a problem. But when bringing a legacy component under test it can lead to code appearing to be tested when it isn’t. This can be avoided by still using exploding fakes within fff. To achieve all of this using the test library all I need in the tests is an include of the appropriate fake header file, #include “CmpEventMgrItf.fff.h” and the test constructor is changed to reset all of the CmpEventMgrItf fakes, set all of the fakes to explode, and then for the two functions that I want to fake I can disable the exploding behaviour. CmpItfTest():m_rResult(ERR_OK),m_InitStruct() { m_rResult = ComponentEntry(&m_InitStruct); FFF_CmpEventMgrItf_FAKES_LIST(RESET_FAKE); FFF_RESET_HISTORY(); FFF_CmpEventMgrItf_FAKES_LIST(FFF_EXPLODE); // Allow normal fake operation for these functions, all others in the interface will explode if called. EventOpen_fake.custom_fake = NULL; EventRegisterCallbackFunction_fake.custom_fake = NULL; } What does the fakes library look like? To show what is included in the library of fakes, for those who are interested below is the content of the CmpEventMgrItf fakes cut down to show just the two functions that have been used. CmpEventMgrItf.fff.h #ifndef __CmpEventMgrItf__FFF_H__ #define __CmpEventMgrItf__FFF_H__ #include "fff.h" #include <string.h> #include "fff_explode.h" #include "CmpEventMgrItf.h" DECLARE_FAKE_VALUE_FUNC3( RTS_HANDLE, EventOpen , EVENTID , CMPID , RTS_RESULT * ); DECLARE_FAKE_VALUE_FUNC2( RTS_RESULT, EventRegisterCallback , RTS_HANDLE , ICmpEventCallback * ); RTS_HANDLE EventOpen_explode( EVENTID , CMPID , RTS_RESULT * ); RTS_RESULT EventRegisterCallback_explode( RTS_HANDLE , ICmpEventCallback * ); #define FFF_CmpEventMgrItf_FAKES_LIST(FAKE) FAKE(EventOpen) FAKE(EventRegisterCallback) #endif /* __CmpEventMgrItf__FFF_H__ */ Other than including headers three things are happening in this file. Firstly the fff fakes are declared, secondly prototypes for exploding functions are declared and finally a list of all faked functions is created allowing operations to be done on all fakes in one statement. CmpEventMgrItf.fff.cpp #include "CmpEventMgrItf.fff.h" DEFINE_FAKE_VALUE_FUNC3( RTS_HANDLE, EventOpen , EVENTID , CMPID , RTS_RESULT * ); DEFINE_FAKE_VALUE_FUNC2( RTS_RESULT, EventRegisterCallback , RTS_HANDLE , ICmpEventCallback * ); RTS_HANDLE EventOpen_explode( EVENTID a, CMPID b, RTS_RESULT * z ){ fff_explode("EventOpen"); return (RTS_HANDLE)0; } RTS_RESULT EventRegisterCallback_explode( RTS_HANDLE a, ICmpEventCallback * z ){ fff_explode("EventRegisterCallback"); return (RTS_RESULT)0; } The fff fakes are defined along with definitions of the exploding fakes. Each exploding fake calls fff_explode, which is declared in a separate module allowing the way it explodes to be changed for a different testing tool.. fff_explode.h #ifndef __FFF_EXPLODE_H__ #define __FFF_EXPLODE_H__ #define FFF_EXPLODE(a) a##_fake.custom_fake = a##_explode; #ifdef __cplusplus extern "C" { #endif void fff_explode(const char * func); #ifdef __cplusplus } #endif #endif /* __FFF_EXPLODE_H__ */ The macro FFF_EXPLODE(a) sets the custom_fake variable in an fff fake to point to the exploding fake. fff_explode.cpp #include "fff_explode.h" #include "gtest/gtest.h" #ifdef __cplusplus extern "C" { #endif void fff_explode(const char * func) { FAIL()<<"Time to use fake for "<<func; } #ifdef __cplusplus } #endif Keeping it fast As I mentioned in the tools section the production code is being built in eclipse. I want to build the test code in eclipse as well, and I want everything to work seamlessly. I added a second Build Configuration to the production code build, and made this build the unit tests. Having done this I want to run the tests every time I build (Or rather I want to run the tests after every code change, and have the code rebuilt if required). This requires an optional component to be installed in eclipse. Go to Help->Install New Software…, choose to Work with: –All Available Sites– and then under Programming Languages select C/C++ Unit Testing Support, click Next>, Next>, Finish and wait for the install to complete. Restart eclipse when prompted. Now right click on your project in eclipse and selectRun As->Run Configurations... Create a new C/C++ Unit Test configuration. Use Search Project to find your Unit Test application, then on the C/C++ Testing tab, select Google Tests Runner. When you run this configuration, it should force your tests to be built and then display the results graphically. Clicking on any failures will take you to the failing tests. Profiling Particularly when bringing legacy code under test, I like to be able to visualise what is being tested and what isn’t. If you are using gcc then this becomes very easy. Add these compiler flags to the compilation of the unit under test, and to the link line. -fprofile-arcs -ftest-coverage Building and then running with profiling generates .gcda and .gcno files, these are specific to a particular build, so to ensure there are no mismatches in versions add to the link rule in the makefile an action to remove all .gcda and .gcno files from the object directory. Now having run your tests look in the object directory in eclipse and you will see .gcda and .gcno files, double click one of them. In the dialog that pops up, ensure that your unit test executable is selected, and choose “Show coverage for the whole selected binary“. For me the key is not the amount of code covered, much more, what has been covered by my tests. Each file can be inspected and it is very clear what was run by the tests and what wasn’t. This helps me decide if I have sufficient coverage before making changes. For example, the bars below show that my tests don’t cover all of the initialisation functions. ExportFunctions is a standard function that is part of all components, the implementation shouldn’t change. The image below shows that the test suite invokes it, but there must be a return statement inside the EXPORT_STMT. Without code coverage I may never have known that some of the code wasn’t being exercised. Inspecting the code will then tell me if I need to add tests or not. This may be a trivial example but I hope it shows why inspecting test coverage helps you understand what is being tested. You can then make informed decisions about increasing the coverage, or accepting that you have gone far enough. Once I’m happy with the coverage in an area I want to change I can start more traditional TDD development. Having started TDD, I tend not to use code coverage checks very often. Being rigorous about TDD tends to lead to 100% coverage, the main time I re-use the coverage checks is if I have refactored the UUT, it helps to show not just that the existing functionality still passes, but that I haven’t inadvertently added some untested functionality. Summary and next steps Investing the time to get the component under test has given me a re-useable test harness that allows me to extend and refactor the code with confidence. Future development can happen much faster than it would otherwise, as much of the functionality can be proven before taking the software anywhere near the embedded target. Some components it is worth investing the time to create pre-canned functionality through custom_fakes. Consider these components SysMem With no further work fff can be used to simulate failures, check the sizes being allocated and return fixed data structures on allocations. However in some tests we just want the memory allocation to work, so having a simple set of custom fakes that can be used to delegate these calls functional equivalents is worth while. Another useful extension can be to track allocation and freeing of memory, then in a test fixture setup tracking can be enabled, and in the teardown it can be checked. CMUtils This component provides string manipulation and other utility functions, in most cases it is preferable to have a working double than the standard fff fake. If you have a source code distribution of the runtime code I would attempt to link this with the tests. SysTime and SysTimeRTC One of the great advantages of Unit Testing in embedded systems is being able to run tests faster than realtime. Develop custom_fakes that allow you to take control of the progress of time. Continuous Integration Tests are only useful when they are run. Setting up a continuous integration system to build and test each component every time there is a change to the source code is the way to go. Continuous Delivery How far can you go towards continuous delivery? Using a combination of free tools, and the CODESYS Test Manager I have set up delivery pipelines that build the embedded code, run unit tests, performed static analysis, generated documentation, package up instrument firmware packages, build and test CODESYS libraries, automated version number management, create CODESYS packages, deploy the code into test systems and invoke automated testing (integration and system). If the tests all pass then the packages can be promoted to potential release candidates ready for final human validation as required.
https://www.cososo.co.uk/tag/eclipse/
CC-MAIN-2021-49
refinedweb
2,942
52.29
How do you remove a movie clip from the stage via a dispatch event?Mr. Baker the Shoe Maker May 1, 2012 6:45 PM I have a movie clip that is added to the stage. There is a close button on that movie clip that I would like to close and remove the clip from the stage. But the close button does not work when it is clicked, nothing happens. Here's the flow along with the code: //Adds the movie clip to the stage var myPlayCredits:mc_playCredits = new mc_playCredits(); stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtons); function goButtons(event:MouseEvent):void { if (event.target == Credits_bnt) { SoundMixer.stopAll(); addChild(myPlayCredits); myPlayCredits.x = 511; myPlayCredits.y = 386; } //This is the code on the button inside the movie clip that calls the dispatch import flash.events.Event; stop(); closeCredit.addEventListener(MouseEvent.MOUSE_DOWN, closeCreditPopupScreen); function closeCreditPopupScreen (event:MouseEvent):void { dispatchEvent(new Event("RemoveMCcredit")); } //Removes (is supposed to remove) the MovieClip from the stage when the user clicks on the close button inside the MovieClip. stage.addEventListener("RemoveMCcredit", RemoveCreditClip); function RemoveCreditClip(e:Event):void { removeChild(myPlayCredits); } Anybody have any thoughts? 1. Re: How do you remove a movie clip from the stage via a dispatch event?Ned Murphy May 1, 2012 7:46 PM (in response to Mr. Baker the Shoe Maker) Why don't you just assign the event listener to the closeCredit button after you instantiate myPlayCredits and just have the event listener call the RemoveCreditClip function directly... var myPlayCredits:mc_playCredits = new mc_playCredits(); myPlayCredits.loseCredit.addEventListener(MouseEvent.CLICK, RemoveCreditClip);\ If you want to use the dispatch event approach, try assigning the listener to the myPlayCredits mc, not the stage. (Or set the Event's bubbling argument to true if you assign it to the stage) 2. Re: How do you remove a movie clip from the stage via a dispatch event?Mr. Baker the Shoe Maker May 3, 2012 9:54 AM (in response to Ned Murphy) Thanks. I assigned the event listener to myPlayCredits. 3. Re: How do you remove a movie clip from the stage via a dispatch event?Ned Murphy May 3, 2012 12:16 PM (in response to Mr. Baker the Shoe Maker) You're welcome
https://forums.adobe.com/message/4377544?tstart=0
CC-MAIN-2016-36
refinedweb
367
58.38
timer_gettime() Get the amount of time left on a timer Synopsis: #include <time.h> int timer_gettime( timer_t timerid, struct itimerspec *value ); Arguments: - timerid - A timer_t object that holds a timer ID, as set by timer_create() . - value - A pointer to a itimerspec structure that the function fills in with the timer's time until expiry. The structure contains at least the following members: - struct timespec it_value - A timespec structure that contains the amount of time left before the timer expires, or zero if the timer is disarmed. This value is expressed as the relative interval until expiration, even if the timer was armed with an absolute time. - struct timespec it_interval - A timespec structure that contains the timer's reload value. If nonzero, it indicates a repetitive timer period. Library: libc Use the -l c option to qcc to link against this library. This library is usually included automatically. Description: The timer_gettime() function gets the amount of time left before the specified timer is to expire, along with the timer's reload value, and stores it in the space provided by the value argument. In order to get timer information, your process must have the PROCMGR_AID_TIMER ability enabled. For more information, see procmgr_ability() . Returns: Errors: - EINVAL - The timer timerid isn't attached to the calling process. - EPERM - The calling process doesn't have the required permission; see procmgr_ability() .
http://developer.blackberry.com/playbook/native/reference/com.qnx.doc.neutrino.lib_ref/topic/t/timer_gettime.html
CC-MAIN-2019-39
refinedweb
226
64
A set of Python utility methods to ease usage of Jupyter notebook Project description A set of Python utility methods to ease usage of Jupyter notebook - Free software: MIT - Source: Installation Install jupyter_utils in Anaconda: $ source activate my_conda_env $ pip install jupyter_utils Note: only dependencies described in requirements.txt will be installed when using pip install. The development dependencies (pylint,…) and not installed on deployment. Usage >From now, on every Jupyter notebook that use this conda environment, you can install any missing anaconda package directly from the cell. Install Anaconda package An anaconda package can be installed directly from the notebook using ! conda install …, but you need to specify the name of the kernel. To simply this, Jupyter Utils provides: from jupyter_utils import conda conda.install("numpy") Grid Search CV on Apache Spark 1.6 Easily distribute Scikit-learn Cross Validation on a Spark Cluster. Only for Spark 1.6.x. For Spark 2, use Sparkit-Learn or Spark-SKLearn. from jupyter_utils.spark import SparkGridSearchCV SparkGridSearchCV(sc, model, params) Contributing Create a virtualenv: $ virtualenv venv $ source venv/bin/activate $ pip install --upgrade pip # Force upgrade to latest version of pip Setup for production: $ pip install -r requirements.txt . Setup for development and unit tests: $ pip install --upgrade -r requirements.txt -r requirements-dev.txt -e . $ python setup.py develop Execute unit tests: $ python setup.py test Code Style: $ python setup.py flake8 $ yapf -r -i jupyter_utils Build: $ # Source package $ python setup.py sdist $ # Binary package: $ python setup.py bdist bdist_wheel Project details Release history Release notifications Download files Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
https://pypi.org/project/jupyter_utils/
CC-MAIN-2018-26
refinedweb
276
50.12
May 21, 2009 10:06 PM|aazizorg|LINK I'm having an issue where I want to be able to reference the class of a UserControl in a page, like this FooControl foo = (FooControl) LoadControl("~/controls/FooControl.ascx"); foo.Bar= "Bazbazbaz"; this.Controls.Add(foo); Where FooControl is a UserControl in the folder "controls". So far I have figured the following out: 1) You must use the @Reference directive at the top of the markup page for each control you want to reference this way (adding an entry in web.config/system.web/pages/controls won't work) 2) You don't need to have the @Register directive or an instance of the control on the page. 3) The control needs to have a "ClassName" attribute defined in it's @Control tag. For inline controls, this is already done. For code-behind, you have to add that to the tag in the ascx file (I've tested it) 4) You can't do this from a code-behind file. It just doesn't work, and complains it can't find the class FooControl ("Compiler Error Message: CS0246: The type or namespace name 'FooControl' could not be found (are you missing a using directive or an assembly reference?)") Point 4 is what I'm trying to figure out. I can't put the control in declaritively in the mark-up, and I don't want to have an interface for every control I need. I haven't been able to find any answers for this question, except maybe one article that I read that said "you can't use code-behind if you want to do this". I'm hoping to get to the bottom of this. I'm hoping some expert out there can give me an answer and tell me a solution. Or at least a definite answer. And if this isn't possible. Why not? Thanks, Anthony Aziz May 22, 2009 03:20 AM|jzimmerman2011|LINK That code should work. If you are not using the type FooControl using the exact namespace and class path (I guess you would call it), then you need to be sure that at the top of the code file, you import the namespace. For example, if your control path is "~/controls/FooControl.ascx" and your project namespace is Project, then instead of: FooControl foo = etc. you must write Project.controls.FooControl foo = etc. unless at the top, you include that namespace, like in C# writing: using Project.controls; granted, this will only work if you did not change the code-behinds namespace, as Visual Studio automatically gives it the namespace based upon Project name and the folder path to where you had it create the control. Star 8270 Points May 22, 2009 12:21 PM|booler|LINK This is caused by changes in the ASP.NET 2.0 compilation model. The new dynamic compilation for pages and user controls has the side-effect of making their types more difficult to reference. The best solution is to create a base class for your control which exposes the functionality you need, and reference that instead. Have a look at this article for more info. HTH May 22, 2009 02:01 PM|aazizorg|LINK Thank you both for replying. Talk about a long article. I'll be sure to look into it in more detail later. I'm going to see if jzimmerman's solution will work first. I have considered creating an interface in App_Code for each control... but that can be annoying, and perhaps there's another way. I'm just confused as to why the difference between code-behind and inline impacts so heavily on this issue. As to referencing the control by namespace, I'll be sure to try that (as soon as I get VS up on this slow computer). I haven't put anything in a namespace (perhaps I should?), so you're saying the FQN is <ProjectName>.controls.FooControl ? (I hope this works for nested folders, as the actual control is ~/controls/reports/ReportForm.ascx. Normally, I wouldn't doubt it, but there's been too many surprises). I'm going to try this out, but one thing I can forsee is not knowing the project name. I'm connected to localhost (and it's not something I can change, this is the way the development machines are set up here). What would the project name be, then? Again, Thanks, I welcome more advice and explanations! May 22, 2009 03:05 PM|jzimmerman2011|LINK it may also depend upon what type of project you are doing. (you mentioned that you have an app_code folder, and i think that app_code folders are only used in web sites, not web apps.) with a web app, you control source files look something like this: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace XUCS.code.controls { public partial class CourseDisplay : System.Web.UI.UserControl { the namespace line is automatically generated to be ProjectNamespace.ParentFolder.ChildFolder for web site projects, the namespace block is removed, but now the class name (that is, if kept as default) reflects the controls folder path. so all there would be to define the control would be public partial class Code_Controls_CourseDisplay : System.Web.UI.UserControl So, if you are using a web site project, then you should already be doing it right, as long as you are sure you are using the full class name on the controls code file. Instead of referring to your code via a general example, could you possibly post (or email me) the actual code you are using? May 22, 2009 03:17 PM|aazizorg|LINK WELL, after restarting VS and waiting 20 minutes for it to load (yeah, I know, a new workstation is in the works...), I believe I've got something. I started with a using clause, then browed through the namespaces IntelliSense brought up. I looked throught the unusualy sounding ones, and found one called "ASP". IntelliSense showed me there were a few classes in there... related to some (but not all) of my UserControls, and no child namespaces. So I simply put "using ASP", and it worked, at least for my test were the page and the control are in the same directory. Now, to test a more realistic situation. I'll post more when I find out more. May 22, 2009 03:27 PM|aazizorg|LINK Sorry jzimmerman, posted before I read your reply. Let me gather the code and post it. I'll have to edit it to take out database and server paths, but the actual code shouldn't be too big an issue. The project is a Web Site Project, I think. How I opened it, Open Website > IIS > localhost. And I tried the full class name (_controls_reports_ReportForm), but it was the same issue. If I put ClassName="ReportForm" in the markup file, I can reference it by that name anyways. The issue was referencing in the code-behind file of an aspx page. I think the namespace was the issue. And I think the ASP namespace only contains controls where you use the <%@ Reference Control="..." %> to reference the file. I'm still testing. Thanks for the advice, again. May 22, 2009 03:32 PM|jzimmerman2011|LINK as long as the control is visible in the namespace you referenced, it really shouldn't matter whether the page is in the same folder as the control. you might want to check the controls that you said were not listed under the namespace, and see which namespace they belong to in their code file, just so you would know for future reference. May 22, 2009 03:41 PM|jzimmerman2011|LINK I just played around with a few things, and in a new web site project, i could only use controls in the code-behind that were referenced in the aspx markup using the <%@ Reference %> tag. The ASP namespace you imported must have been written into the control code files, it is not generated by default i dont believe. if you check a control's code that is in that namespace, then it probably has the ASP namespace declaration. The controls that you noticed were missing probably have not had that namespace added to them yet. Actually, i think you are right about the ASP namespace thing. I added a reference tag to a page real quick, and the class appeared in the ASP namespace. May 22, 2009 04:08 PM|aazizorg|LINK Okay, I figured it out (with help to you guys, of course!). The namespace is "ASP" for this website. I don't know why, but it is. I'll give a little background. I started at this company in October, and I didn't start working on the web application until February. The software is a subscriber based web application spread across multiple server farms. It was originally done in classic ASP, and only a few new parts are being coded in ASP.NET (my Crystal Reports module is one of them). Everyone has a copy of the webapp in there local IIS folder, so I connect to the website under localhost IIS. It has a lot of .asp and other files, so it's not a deployed project. I save the pages I work on, then browse to to test. There is no namespace in the code-behind files. From your post it sounds likes the ASP namespace is the default namespace for controls referenced. Anyways, this works for me. I'll post the relevant code. You won't be able to run it, there's some framework objects there that are just to complicated to post. Here's the page: <%@ Page <html xmlns=""> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:PlaceHolder</asp:PlaceHolder> </div> </form> </body> </html> And the code behind: ASP; public partial class _test_ReferencingControlsIncodeBehind : System.Web.UI.Page { protected override void OnInit(EventArgs e) { WebUserControlInline inline = (WebUserControlInline)LoadControl("WebUserControlInline.ascx"); inline.Text = "INLINE"; placeholder.Controls.Add(inline); WebUserControlCodebehind codebehind = (WebUserControlCodebehind)LoadControl("WebUserControlCodebehind.ascx"); codebehind.Text = "CODE BEHIND"; placeholder.Controls.Add(codebehind); ScheduledReports scheduledReports = (ScheduledReports)LoadControl("~/controls/reports/ScheduledReports.ascx"); XmlReportScheduler scheduler = new XmlReportScheduler(Application["app_imagingserver1"].ToString(), 479); scheduler.oabcode = 0; scheduledReports.LoadSchedules(scheduler, 479); placeholder.Controls.Add(scheduledReports); base.OnInit(e); } } And the ReportScheduler.ascx <%@ Control Language="C#" AutoEventWireup="false" CodeFile="ScheduledReports.ascx.cs" Inherits="controls_reports_ScheduledReports" ClassName="ScheduledReports"%> <asp:Repeater <HeaderTemplate> <table> <tr> <td>Scheduled Report <em>(Click to modify)</em></td> <td>Created By</td> <td>Last Modified</td> <td>Last Ran</td> <td>Delete</td> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><asp:LinkButton<%# ((ScheduledReport)Container.DataItem).File.Replace(".xml", "") %></asp:LinkButton></td> <td><%# ((ScheduledReport)Container.DataItem).UserId %></td> <td><%# ((ScheduledReport)Container.DataItem).Modified.ToString(XmlReportScheduler.LIF_DATE_FORMAT) %></td> <td><%# ((ScheduledReport)Container.DataItem).LastRan > DateTime.MinValue ? ((ScheduledReport)Container.DataItem).LastRan.ToString(XmlReportScheduler.LIF_DATE_FORMAT) : "Never" %></td> <td><asp:LinkButtonDelete</asp:LinkButton></td> </tr> </ItemTemplate> <FooterTemplate> <tr> <td colspan="5">Total scheduled reports: <%# Container.ItemIndex %></td> </tr> </table> </FooterTemplate> </asp:Repeater> And it's code behind: using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; public partial class controls_reports_ScheduledReports : System.Web.UI.UserControl { public event CommandEventHandler EditSchedule; public event CommandEventHandler DeletedSchedule; protected override void OnLoad(EventArgs e) { reportList.ItemCommand += new RepeaterCommandEventHandler(reportList_ItemCommand); base.OnLoad(e); } public void LoadSchedules(XmlReportScheduler scheduler, int mabcode) { List<ScheduledReport> reports = scheduler.GetScheduledReportSummaries(mabcode); if (reports.Count < 1) { reportList.Controls.Clear(); reportList.DataSource = null; } else { reportList.DataSource = reports; reportList.DataBind(); } } private void reportList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "edit") { if (EditSchedule != null) { EditSchedule(this, new CommandEventArgs("filename", e.CommandArgument)); } } else if (e.CommandName == "delete") { if (DeletedSchedule != null) DeletedSchedule(this, new CommandEventArgs("filename", e.CommandArgument)); } } } May 22, 2009 04:10 PM|jzimmerman2011|LINK the more i think about it, i dont think that you can use namespaces in code files, since you are using a web site project. with a web app project, all the code is compiled into an actual .dll library, whereas with a web site, the code is not compiled this way. since with a web app all the code is in one assembly, it can contain things like namespaces, but with a web site, the code files are just code files, and since they are not in an assembly, they cannot be contained in things like namespaces. May 22, 2009 04:19 PM|jzimmerman2011|LINK from what ive been playing around with (i use web apps instead of web sites, so i dont know too much about their differences), it seems that the ASP namespace is an "on-the-fly" namespace. if you have two different pages, and look at the ASP namespace for each, then you will find that they do not show the same things. by default, it looks as if for each page, their ASP namespace allows access to the current page for which you are working on. then, when you add Reference tags, the controls you reference for that page become visible only in that pages ASP namespace. (this would explain why earlier, not all of the controls in the directory where you put them were visible in the ASP namespace). as i said in my previous post, web sites are not compiled into an assembly. This would also mean that your web site project does not actually have a namespace to it. May 22, 2009 04:22 PM|aazizorg|LINK Yeah, I've read into the Website-VS-Webapp bit, and see what you mean. Well, I edited my above post, that solution worked. The rules as I understand them: May 22, 2009 04:40 PM|jzimmerman2011|LINK aazizorg - The control needs to have a ClassName tag in the <%@ Control %> tag (actually, I think if it doesn't you'll use the generated class name?) ClassName i believe will only override the name of the class as defined in the code-behind. May 22, 2009 04:42 PM|aazizorg|LINK I think I've got a work around for that problem that better suits the situation anyways. You actually helped me a lot. I didn't know what kind of response I'd get on these forums, but so far looks pretty helpful, I'm glad I posted. 14 replies Last post May 22, 2009 04:42 PM by aazizorg
http://forums.asp.net/t/1426138.aspx
CC-MAIN-2015-06
refinedweb
2,427
58.48
DotNetStories In this post I will show you with a hands-on demo the enum support that is available in Visual Studio 2012, .Net Framework 4.5 and Entity Framework 5.0. You can have a look at this post to learn about the support of multilple diagrams per model that exists in Entity Framework 5.. You can search in my blog, because I have posted many posts regarding ASP.Net and EF. I assume you have a working knowledge of C# and know a few things about EF.) Create a new folder. Name it CodeFirst . 5) Add a new item in your application, a class file. Name it Footballer.cs. This is going to be a simple POCO class.Place it in the CodeFirst folder. The code follows public class Footballer { public int FootballerID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public double Weight { get; set; } public double Height { get; set; } public DateTime JoinedTheClub { get; set; } public int Age { get; set; } public List<Training> Trainings { get; set; } public FootballPositions Positions { get; set; } } Now I am going to define my enum values in the same class file, Footballer.cs public enum FootballPositions { Defender, Midfielder, Striker } 6) Now we need to create the Training class. Add a new class to your application and place it in the CodeFirst folder.The code for the class follows. public class Training { public int TrainingID { get; set; } public int TrainingDuration { get; set; } public string TrainingLocation { get; set; } }; } public DbSet<Training> Trainings { get; set; } } Do not forget to add (using System.Data.Entity;) in the beginning of the class file 8). In my case the connection string inside the web.config, looks like this <connectionStrings> <add name="CodeFirstDBContext" connectionString="server=.\SqlExpress;integrated security=true;" providerName="System.Data.SqlClient"/> </connectionStrings> where player.FirstName=="Jamie" select player; return query.ToList(); } } your application. 11) Let's create an Insert method in order to insert data into the tables. I will create an Insert() method and for simplicity reasons I will place it in the Default.aspx.cs file. private void Insert() { var footballers = new List<Footballer> { new Footballer { FirstName = "Steven",LastName="Gerrard", Height=1.85, Weight=85,Age=32, JoinedTheClub=DateTime.Parse("12/12/1999"),Positions=FootballPositions.Midfielder, Trainings = new List<Training> { new Training {TrainingDuration = 3, TrainingLocation="MelWood"}, new Training {TrainingDuration = 2, TrainingLocation="Anfield"}, new Training {TrainingDuration = 2, TrainingLocation="MelWood"}, } }, new Footballer { FirstName = "Jamie",LastName="Garragher", Height=1.89, Weight=89,Age=34, JoinedTheClub=DateTime.Parse("12/02/2000"),Positions=FootballPositions.Defender, Trainings = new List<Training> { new Training {TrainingDuration = 3, TrainingLocation="MelWood"}, new Training {TrainingDuration = 5, TrainingLocation="Anfield"}, new Training {TrainingDuration = 6, TrainingLocation="Anfield"}, } } }; footballers.ForEach(foot => ctx.Footballers.Add(foot)); ctx.SaveChanges(); } 12) In the Page_Load() event handling routine I called the Insert() method. protected void Page_Load(object sender, EventArgs e) { Insert(); } 13) Run your application and you will see that the following result,hopefully. You can see clearly that the data is returned along with the enum value. 14) You must have also a look at the database.Launch SSMS and see the database and its objects (data) created from EF Code First. Have a look at the picture below. Hopefully now you have seen the support that exists in EF 5.0 for enums. Hope it helps !!!
http://weblogs.asp.net/dotnetstories/looking-into-enum-support-in-entity-framework-5-0-code-first
CC-MAIN-2015-40
refinedweb
546
51.34
[ ] Michael Miller commented on ACCUMULO-4681: ------------------------------------------ After starting to work on this task, I am now wondering if a weak ref map should also be created for Namespace. This is only an issue in one part of the code where I had written Utils.getNextTableId() to use reflection to call the generic constructor of AbstractId type. So unless I also create a Namespace.ID.of(namespaceId) I will have to rewrite this method to call the static "of" method for Table and public constructor for Namespace. > Create WeakReference Map to replace Table.ID constructor > -------------------------------------------------------- > > Key: ACCUMULO-4681 > URL: > Project: Accumulo > Issue Type: Improvement > Reporter: Michael Miller > Assignee: Michael Miller > Priority: Minor > Fix For: 2.0.0 > > > Taken from feedback on the PR #279: > Could maybe avoid duplicates by making constructor (of Table.ID) private and doing Table.ID.of(tableId), which draws from an internal WeakReference map. > If the object deduplication in KeyExtent is still valid, this can be pushed down to the Table.ID and Namespace.ID classes, replacing the optimization in KeyExtent. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
http://mail-archives.apache.org/mod_mbox/accumulo-notifications/201708.mbox/%3CJIRA.13088079.1500414932000.120322.1502219700489@Atlassian.JIRA%3E
CC-MAIN-2017-43
refinedweb
185
59.4
Applicaton icon Qt5.2, Windows and Linux, QML Hello!! Very simple problem: I can not figure out how to change the application icon from default (the icon on the top left of the window). From,, it seems I just need to call, "the QWindow::setWindowIcon() method". The code below is from main.cpp. QGuiApplication doesn't have a setWindowIcon(). I can't find any methods to set window icon. I see RC_ICONS for qmake but we are using CMake... @#include <QtQuick> int main(int argc, char *argv[]){ QGuiApplication app(argc, argv); QQmlApplicationEngine engine(QUrl("qrc:/resources/qml/main.qml")); return app.exec(); }@ Please advise me how to set the applicaton icon in Qt5.2 (QML app). Sincere thanks! p.s. I'm sure this is covered in another post but I'm having problems searching posts for some reason. Hi, QGuiApplication has " setWindowIcon()":. To use, @ QGuiApplication app(argc, argv); app.setWindowIcon(QIcon(QPixmap("/root/clover.png"))); @ Thank you so much for responding (rapidly)! I thought it would be something like that but adding the line of code, "app.setWindowIcon(QIcon(QPixmap("/root/clover.png")));" is acting like QGuiApplication doesn't have a setWindowIcon method: [ 76%] Built target isbuild /home/jwicks/MCG/main.cpp: In function ‘int main(int, char**)’: /home/jwicks/MCG/main.cpp:25:9: error: ‘class QGuiApplication’ has no member named ‘setWindowIcon' What the heck?! Thank you sir. jw That's weird. Can you post complete contents of main.cpp ? Please use code tags '@@' for pasting the code here. Yes, this is it. Everything else is happening in main.qml. @#include <QtQuick> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine(QUrl("qrc:/resources/qml/main.qml")); return app.exec(); }@ I have an idea; I can try to grep Qt source code for setWindowIcon(). grepping... Well, I found, "/opt/Qt5.2/5.2.1/gcc_64/include/QtWidgets/qapplication.h: static void setWindowIcon(const QIcon &icon); " Since it's static, I did: QApplication::setWindowIcon(QIcon(QPixmap("/images/image.ico"))); I don't see the icon yet though... Am I calling it correctly? Thanks again! UPDATE: I tried something else but still not working. Note, I'm using Linux ~ maybe that has something to do with it? @#include <QtQuick> #include <QApplication> int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setWindowIcon(QIcon(":/resources/images/new_blue.png")); QQmlApplicationEngine engine(QUrl("qrc:/resources/qml/main.qml")); return app.exec(); }@ Is it giving any error now or it is not just displaying icon ? Instead of loading from resource try it from a fixed path. For e.g @ app.setWindowIcon(QIcon("/root/new_blue.png")); @
https://forum.qt.io/topic/42914/applicaton-icon-qt5-2-windows-and-linux-qml
CC-MAIN-2018-34
refinedweb
435
54.39
Misc #15568open TracePoint(:raise)#parameters raises RuntimeError Description Currently trying to get the trace.parameters of a method in a raise event will lead to a RuntimeError. I would contend that it should not, and that it would be perfectly valid to ask for the parameters in the case of an exception. The reason I do this is to see the arguments at the time of exception: def extract_args(trace) trace.parameters.map(&:last).to_h do |name| [name, trace.binding.eval(name.to_s)] end end I've noticed that I can technically "cheat" and get these same values like this: def extract_args(trace) trace.binding.eval('local_variables').to_h do |name| [name, trace.binding.eval(name.to_s)] end end Having the ability to get the parameters in a raise context would be very useful for debugging. I'm tempted to also suggest TracePoint#local_variables as it would provide additional context in a more exposed way than TracePoint#binding.eval('local_variables') Updated by shevegen (Robert A. Heiler) over 2 years ago Having the ability to get the parameters in a raise context would be very useful for debugging. I agree. I can't say whether this means that trace.parameters exist but I agree that it may be useful in debugging/introspection. I'm tempted to also suggest TracePoint#local_variables as it would provide additional context in a more exposed way than TracePoint#binding.eval('local_variables') I can't say whether TracePoint#local_variables makes sense; but since the .eval() variant works, I can see that it may just be a prettier and shorter name. I think it would be helpful to ask the ruby core team about the API part here specifically, especially koichi and matz. I am not a big user of TracePoint myself so I can not really speak about how useful it would be, but being able to shorten the API and omitting eval, would seem ok to me. But perhaps others prefer eval(), I don't know; eval() has a tiny bit of a hackish feeling to me personally though (I only mean eval(), not the instance_eval() variants and the like). It seems an API consideration to me though and a language designer's consideration (e. g. how matz would encourage ruby users to make use of TracePoint; it's also a design decision what to enable or not to enable). Also available in: Atom PDF
https://bugs.ruby-lang.org/issues/15568
CC-MAIN-2021-31
refinedweb
398
54.93
Answered by: DateTime Picker null value Question Answers All replies You can use the checbox property of the datetimepicker When you save to your database you do Dpar.IsNullable =True Dpar.Value = IIf(DTP1.Checked, DTP1.Value, DBNull.Value) When you read from your database you do Me.DTP1.Value = IIF(tabla.Rows(0)(row(0)("field").ToString) IsDBNull.Value, Date.Now, tabla.Rows(0)(row(0)("field").ToString)) Me.DTP1.Checked = Not (tabla.Rows(0)(row(0)("field").ToString) Is DBNull.Value) - I have had the similar problem. I did the workaround is that, when the user inputs nothing in the datetime field va lues, I make the datetime variable to maxvalue and save it to database, and when retrieiving from the database, I checked if its max value then display nothing. This will throw an error: "Object reference not set to an instance of an object." - of course, date format cannot be set to some null or emply space value. Maybe this way possible inth .net 3.0 and older, but not int 3.5 and 4.0. BARBI: what exactly would you like to achive? Wow, did I burn a ton of time on this one! I found that you can databind to the Tag property, and it will take DBNull.Value, which makes the database do the right things. Then it was on to the task of keeping the picker Value and Tag properties in sync, and dealing with all manner of UI/event weirdness. Thanks Microsoft, for not implementing null for this control, and double thanks for not fixing it after all these years. One of the problems is that by using CustomFormat, we hard code the display format of DateTime values in the picker, losing features of locale. But switching the Format property on the fly has serious issues: it causes databinding and the enter event to happen again! More problems: using ValueChanged event is no good. It fires when you change the format (because technically, the Text property does change when you change the format). Also, when Leave fires, Enter also fires (without firing Leave again). To deal with these sad facts there is much to do. Here is my vanilla implementation of the solution. Not for those looking for an easy fix: // Make sure picker databinds to Tag prop, not Value prop! // Make sure to set picker.CustomFormat to a single space (" " w/o quotes) namespace SEITracker { public partial class MyForm : SEITracker.BaseForm { // Since Enter event fires when leaving and when changing format, // use a pseudo-semaphore to signal the Enter event not to muck things up bool DateTimePickerBinding = false; DateTime nullDate = new DateTime(1900, 1, 1); DateTimePickerFormat dateTimePickerFormat = DateTimePickerFormat.Short; string dateTimePickerNullFormat = " "; private void Idea_Load(object sender, EventArgs e) { ... // You can set these in the designer and skip these 2 lines picker1.Format = dateTimePickerFormat; picker1.CustomFormat = " "; // Signifies null ...<br/> } // This is how the user signals to empty the field. You // can use the checkbox and it's Checked event instead // i.e., if (!picker.Checked) SetDateTimePickerNull(picker); // The important thing here is to set the pseudo-semaphore // before and unset after. See comments below private void picker1Label_Click(object sender, EventArgs e) { // Since Enter event fires when *leaving* AND when *changing format*, // use a pseudo-semaphore to signal the Enter event not to muck things up DateTimePickerBinding = true; SetDateTimePickerNull(picker1); DateTimePickerBinding = false; } private void DateDateTimePicker_Enter(object sender, EventArgs e) { DateTimePicker picker = (DateTimePicker)sender; // If value empty (user sees blank value), set default value and format for picking a value if (picker.Format == DateTimePickerFormat.Custom && !DateTimePickerBinding) { // Because changing the format will cause binding to the datasource, // all we have to do is set the bound property (Tag) and change the format picker.Value = DateTime.Parse(UTCDateTime.Now()); // Warning: Causes rebinding, and kills message to picker to expand. // user would get the current date filled in on first click, then user // will have to click again to get the calendar to pop out picker.Format = dateTimePickerFormat; // Solution: (Thanks Zep @ social.msdn.microsoft.com) SendKeys.Send("%{DOWN}"); // Opens calendar again } } private void DateDateTimePicker_Leave(object sender, EventArgs e) { DateTimePicker picker = (DateTimePicker)sender; if (picker.Value == nullDate) { // Hide display of value from the user if (picker.Format != DateTimePickerFormat.Custom) picker.Format = DateTimePickerFormat.Custom; } else { // Sync with the databound property picker.Tag = picker.Text; } } private void SetDateTimePickerNull(DateTimePicker picker) { picker.Tag = DBNull.Value; picker.Value = nullDate; // POOF! It's Magic! Don't worry, this sets currentvalue only, so ADO // does pick up the change when Update() called on the datasource picker.DataBindings[0].WriteValue(); // Warning: Causes rebinding. So, we have to sync the datasource manually // with the line above before changing the format, else the Value prop gets // reset to the db value when EndEdit() called // Also, this causes the Enter event to fire. Crap! That causes the date // to flip back to a value with the SendKeys in the Enter event // Solution: set DateTimePickerBinding semaphore before calling this function picker.Format = DateTimePickerFormat.Custom; } ... } }
http://social.msdn.microsoft.com/Forums/windows/en-US/f1f8cc0a-0ac9-4a3e-9ba4-9af495e8ff58/datetime-picker-null-value?forum=winforms
CC-MAIN-2014-15
refinedweb
826
56.45
Connector/C++ 8.0 implements the X DevAPI, as described in the X DevAPI User Guide. The X DevAPI allows one to work with MySQL Servers implementing a document store via the X Plugin. One can also execute plain SQL queries using this API. To get started, check out some of the main X DevAPI classes: Sessionobject. Keep in mind that Sessionis not thread safe! Collectionor a Tableobject using methods getCollection()or getTable()of a Schemaobject obtained from the session. Collectionor Tableclass, such as find(). They are executed with method execute(). DocResultor RowResultinstances returned from execute()method. Method fetchOne()fetches the next item (a document or a row) from the result until there are no more items left. Method fetchAll()can fetch all items at once and store them in an STL container. DbDocand Rowinstances, respectively. A more complete example of code that access MySQL Document Store using the X DevAPI is presented below. See also the list of X DevAPI classes. The following Connector/C++ application connects to a MySQL Server with X Plugin, creates a document collection, adds a few documents to it, queries the collection and displays the result. The sample code can be found in file testapp/devapi_test.cc in the source distribution of Connector/C++ 8.0. See Using Connector/C++ 8.0 for instructions on how to build the sample code. Code which uses X DevAPI should include the mysql_devapi.h header. The API is declared within the mysqlx namespace: To create an Session object, specify DNS name of a MySQL Server, the port on which the plugin listens (default port is 33060) and user credentials: Another way of specifying session parameters is by means of a mysqlx connection string like "mysqlx://mike:s3cr3t!@localhost:13009". Once created, the session is ready to be used. If the session can not be established, the Session constructor throws an error. To manipulate documents in a collection, create a Collection object, first asking session for that collection's Schema: The true parameter to createCollection() method specifies that collection should be re-used if it already exists. Without this parameter an attempt to create an already existing collection produces an error. It is also possible to create a Collection object directly, without creating the Schema instance: Before adding documents to the collection, all the existing documents are removed first using the Collection::remove() method (expression "true" selects all documents in the collection): Note that the remove() method returns an operation that must be explicitly executed to take effect. When executed, operation returns a result (ignored here; the results are used later). To insert documents use the Collection::add() method. Documents are described by JSON strings using the same syntax as MySQL Server. Note that double quotes are required around field names and they must be escaped inside C strings, unless the new C++11 R"(...)" string literal syntax is used as in the example below: Result of the add() operation is stored in the add variable to be able to read identifiers of the documents that were added. These identifiers are generated by the connector, unless an added document contains an "_id" field which specifies its identifier. Note how internal code block is used to delete the result when it is no longer needed. add()calls as follows: coll.add(doc1).add(doc2)...add(docN).execute(). It is also possible to pass several documents to a single add()call: coll.add(doc1, ..., docN).execute(). Another option is to pass to Collection::add()an STL container with several documents. To query documents of a collection use the Collection::find() method: The result of the find() operation is stored in a variable of type DocResult which gives access to the returned documents that satisfy the selection criteria. These documents can be fetched one by one using the DocResult::fetchOne() method, until it returns a null document that signals end of the sequence: Given a DbDoc object it is possible to iterate over its fields as follows: Note how the operator[] is used to access values of document fields: The value of a field is automatically converted to a corresponding C++ type. If the C++ type does not match the type of the field value, conversion error is thrown. Fields which are sub-documents can be converted to the DbDoc type. The following code demonstrates how to process a "date" field which is a sub-document. Note how methods DbDoc::hasField() and DbDoc::fieldType() are used to examine existence and type of a field within a document. In case of arrays, currently no conversion to C++ types is defined. However, individual elements of an array value can be accessed using operator[] or they can be iterated using range for loop. Any errors thrown by Connector/C++ derive from the mysqlx::Error type and can be processed as follows: The complete code of the example is presented below: A sample output produced by this code:
https://dev.mysql.com/doc/dev/connector-cpp/8.0/devapi_ref.html
CC-MAIN-2021-10
refinedweb
823
53.92
How to Use an LCD - Arduino Introduction: How to Use an LCD - Arduino Let's learn how to use an LCD (Liquid Crystal Display) with an Arduino board. Step 1: Hardware Needed -An Arduino Uno -A breadboard -Jumper wires -A 10K potentiometer -And an LCD of course ! You won't need any tool. Step 2: Build the Circuit The steps here correspond to the image above... First, pin your LCD on the breadboard and power the breadboard by connecting a wire from "5V" (power) on your LCD to the central pin of the 10K potentiometer. Finally, power the potentiometer with one pin on GND and the other one on 5V (on the breadboard). Step 3: Code Now let's write the code... #include <LiquidCrystal.h> //Include the library that enables you to use the LCD. LiquidCrystal lcd(2,3,4,5,6,7);//Declare that your LCD is connected to pins 2,3,4,5,6 & 7 on your arduino. void setup() { lcd.begin(16, 2);//16 by 2 are the dimensions of the LCD (in number of characters) lcd.print("My name is Bond");//print "My name is Bond," on the LCD lcd.setCursor(0, 1); //break a line lcd.print("controlled LCD!");//print "James Bond" on the second line of the LCD. } void loop() { } I'm a beginner..and this is my first try..Thanks a ton! I Made It! :) congrats! thanks for sharing;) Thank you for your reply I would like learn Arduino / LCD microcontrllemicrcontroller Programming Thanks I learned the basics with autodesk 123d circuits and with their YouTube tutorials and then, I bought the Arduino starter kit and partly learned from the book inside and from Roman Kozak's YouTube channel. It is interesting to start with 123d circuits because you can program, design, and simulate your project for free. And the Arduino starter kit is cool because it has a great book inside, many components and it is not very expensive... Thank you the info I am new to programming. Can you please tell me where to start ? Thanks Hi, Would you like to start learning computer programming (apps, games...) or electronic programming (microcrontrollers like Arduino, small electronic devices like LCDs...) ?
http://www.instructables.com/id/How-to-use-an-LCD-Arduino/
CC-MAIN-2017-47
refinedweb
366
74.79
One of our growing series on building a mobile chat app with React Native and PubNub. PubNub provides our realtime messaging chat APIs and backend, and React Native Gifted Chat provides a complete chat UI for our app. In this case, we’ll use the PubNub React package, which is a wrapper for the PubNub JavaScript SDK (v4). It simplifies the PubNub integrations with React or React Native. In the end, we’ll have a simple mobile group chat app that allows multiple users to message one another in realtime. From there, we’ll continue adding new chat features including message history, user online/offline status, and typing indicators. Requirements Before we begin, make sure you have the following: - Node.js installed, along with NPM or yarn. - A PubNub account; this is where you’ll get your unique publish/subscribe keys. - Two (or more) mobile devices to test the app. Set Up In this step, we’ll create a React Native project using the following command: react-native init pubnubchatwithreactnative Open the project folder named ‘pubnubchatwithreactnative’ with VSCode or your favorite code editor. Next, open an integrated terminal and run the Android and iOS simulator by using the following code snippets: react-native run-ios react-native run-android Note: It will take a considerable amount of time for the first build of the React project. After the build, you will see the following on your Android and iOS simulators. UI: Installing the Gifted Chat UI Package In this step, we are going to install the Gifted Chat package, providing us with a complete chat UI. You can install react-native-gifted-chat with using following commands: npm install react-native-gifted-chat --save yarn add react-native-gifted-chat Grab the example code from the GitHub readme file and paste it into the App.js file. Next, import the GiftedChat component/module from the react-native-gifted-chat package as shown in the code snippet below: import { GiftedChat } from 'react-native-gifted-chat' Replace the code in the default class with the following piece of code: export default class App extends Component { state = { messages: [], }; componentWillMount() { this.setState({ messages: [ { _id: 1, text: "Hello developer", createdAt: new Date(), user: { _id: 2, name: "React Native", avatar: "", }, }, ], }); } onSend(messages = []) { this.setState(previousState => ({ messages: GiftedChat.append(previousState.messages, messages), })); } render() { return ( <GiftedChat messages={this.state.messages} onSend={messages => this.onSend(messages)} user={{ _id: 1, }} /> ); } } As seen in the code snippet above, the onSend() function is used for collecting messages and concatenating with the previous message. You’ll see it in the chat UI. The imported component GiftedChat is used to cover the whole chat interface. You need to save the code and refresh the simulators. You will see an example message. Keep in mind that you will not be able to send messages because PubNub is not yet implemented. Messaging and Backend: Implementing PubNub Now that we’ve got our UI ready to go, it’s time to make our chat app interactive – allowing users to communicate in realtime. That’s where PubNub comes in. In this step, we’ll install the PubNub SDK. You can install the package using the following commands. Using NPM: npm install pubnub-react --save Using Yarn: yarn add pubnub-react Once the installation is done, you need to import the PubNubReact module from the pubnub-react package as shown in the code: import PubNubReact from 'pubnub-react'; Next, you can copy the example code from README file of the PubNub React GitHub, and paste it into the App.js file of your project: constructor(props) { super(props); this.pubnub = new PubNubReact({ publishKey: 'YOUR PUBLISH KEY', subscribeKey: 'YOUR SUBSCRIBE KEY' }); this.pubnub.init(this); } componentWillMount() { this.pubnub.subscribe({ channels: ['channel1'], withPresence: true }); this.pubnub.getMessage('channel1', (msg) => { console.log(msg); }); this.pubnub.getStatus((st) => { console.log(st); this.pubnub.publish({ message: 'hello world from react', channel: 'channel1' }); }); } componentWillUnmount() { this.pubnub.unsubscribe({ channels: ['channel1'] }); } Next, add your unique pub/sub keys you got when you signed up for PubNub. They’re available in your PubNub Admin Dashboard. Save and re-run the simulator. To view the JavaScript console output, we need to use Debug JS remotely. You will now be able to see PubNub data in the browser console. With that, the PubNub implementation is complete. Next, we need to configure the chat channel using PubNub as set it up along with Gifted Chat. Follow these simple steps: - Initialize PubNub (done) - Subscribe to channel name “channel1” with the SDK subscribe method. - Send a message to “channel1” with the publish method. - Get a message from a channel with getMessagemethod. Putting It All Together In this step, we bring the entire configuration together. We pass a message from Gifted Chat to the PubNub publish() method. You can use the example code from the code snippet below. onSend(messages = []) { this.pubnub.publish({ message: messages, channel: "Channel1", }); } When the callback function onSend() is called, we will send message to Channel1. To get a message from the channel in realtime, we use the following callback to append previous state messages. Here is the code: this.pubnub.getMessage("ReactChat", m => { this.setState(previousState => ({ messages: GiftedChat.append(previousState.messages, m["message"]), })); }); All done! Let’s try it out by reloading the simulators. Now you should see the following in your simulator. You will see chat messages appear in the UI, but all the messages appear on the same side. We need to graphically separate messages sent from messages received, to make it appear that two people are chatting. <GiftedChat messages={this.state.messages} onSend={messages => this.onSend(messages)} user={{ _id: 0, }} /> This is because we haven’t set a new id when we open a new session. We need to hard code the user id. Create a function in App.js for generating a random user id, as shown in the code snippet below. randomid = () => { return Math.floor(Math.random() * 100); }; Set the variable and add it to the constructor function in App.js. this.id = this.randomid(); Lastly, add the state and function to the GiftedChat HTML, as shown in the code below. <GiftedChat messages={this.state.messages} onSend={messages => this.onSend(messages)} user={{ _id: this.id, }} /> Now, reload the simulator and observe the result. You will see the chat messages appear on the other side. At last! We have completed the setup of a chat app using React Native along with Gifted Chat and PubNub. Wrapping Up In this tutorial, we learned how to create a simple chat app with React Native using Gifted Chat and PubNub. You’ve now got a basic mobile chat application allowing users to send and receive messages in realtime. Next step is to start adding additional chat features – message history, typing indicators, user presence, etc. Keep an eye out for subsequent posts on that! All the code for this tutorial is available in my GitHub repo. The post Building a React Native Chat App – Part One: Basic Messaging appeared first on PubNub. Discussion (3) Hello, I'm having issues running the app I'm my Android emulator. Giving me some sort of JDK not added in path error. your can create a new project and only copy src and App.js then install require package like pubnub it simple solution for solve environment error Awesome. Will try it out
https://practicaldev-herokuapp-com.global.ssl.fastly.net/kris/building-a-react-native-chat-app-part-one-basic-messaging-39dl
CC-MAIN-2021-25
refinedweb
1,220
58.18
TL;DR: use> include: function(absPath){ return (/[regex for the module(s) you want to include]/.test(absPath) || /src/.test(absPath)); }, instead of> exclude: /node_modules/, I’m currently working on a project that required some client side validation for credit cards and found this amazing module with pretty much everything I needed in npm: My project setup includes React, Redux and, of course, Webpack. So I npm-installed that bad boy and everything went as expected; it also worked like a charm with redux-form validators. But, as you know, there’s no such a thing as “smooth sailing” in web development: if something can go wrong it will. And it went. The problem with non-transpiled modules It turns out that the credit-card module is not distributed as a transpiled module so, when you install it you get the code in ES6. This wasn’t a problem for development but when the moment came for me to test the deployment/build scripts tragedy struck: the process simply failed and Webpack was showing one of those cryptic error messages we all know and love. I couldn’t believe it. Damn it! I started checking for the usual stuff: node versions, outdated packages, cache… Nothing helped. And then, it struck me like a lightning and I navigated to the credit-card directory just to confirm it: the code wasn’t distributed in ES5. That was the issue. According to this GH issue, the module maintainer didn’t want to transpile the code because: 1. It’s just a pain to manage. 2. It’s weird to test because you’re testing es2015 code that works fine on Node, but people are using transpiled babel code on the client that isn’t tested at all. 3. You become dependent on the babel ecosystem which has had some serious bumps during the 5.x.x to 6.x.x transition. 4. By not using the actual source, you lose a lot of optimization flexibility from within webpack/browserify To be fair those are valid reasons and even if you consider that they’re not you’ll have to deal with it, you either figure out how to fix it yourself or you use another package. I wanted to fix it but I’m not what you’d call a Webpack expert. The more you know Just to make it clear I didn’t stumble across the aforementioned issue until some time later so I spent some time stumbling across StackOverflow and Webpack’s docs I knew I had to somehow transpile the module by myself, but I also knew I was excluding the node_modules folder so I started playing around with different combinations of exclude and include . Then, I discovered that exclude takes precedence over include so, if you have both only the exclude will work. When I discovered this I was frustrated and, happily, stumbled across the issue so I decided to post a question and grab lunch. Adam was kind enough to answer my question and I discovered something new: include can take a function that receives the absolute path of each file Webpack is processing and returns true or false depending on whether you want to include it or not. Then Webpack will run every file path though this function and operate over the file only if the result of executing it is true . After that, configuring my build took like 2 minutes, I just added a couple of regular expressions to match the specific module (credit-card) and the src folder in my project: include: function(absPath){ return (/credit-card/.test(absPath) || /src/.test(absPath)); }, instead of the original: exclude: /node_modules/, Also, Webpack’s documentation encourages the use of include over exclude so it was a double-kill. 评论 抢沙发
http://www.shellsec.com/news/20809.html
CC-MAIN-2017-09
refinedweb
632
55.98
Tax Have Tax Questions? Ask a Tax Expert for Answers ASAP Hi Thanks for your question You will continue to do what you have been doing (adding the income into the partnership income) and claiming the allowable business expenses, the only difference is that you also should have been filling in this income/expenses information on a foreign income page so that HMRC knew how much of your partnership income was paid from a foreign source. (and up until now this would not need to show foreign tax suffered as it had not been) From now on, you still have to complete the foreign income page (as well as show this within the partnership income) , along with the with holding tax suffered so that HMRC do not make you suffer tax twice on the same income. Thanks Sam Thanks for this. Are we talking about the foreign income page on my personal tax return (ie SA106)? And where exactly do I show income/expenses tax paid on my partnership return (I use a short statement). Thanks again. Graham Hi Graham Thanks for your response No on the supplementary foreign page on the partnership return. SA802 see link here As you advised this was money earned through the partnership. Then the income on the main partnership will be added within as a total income, and the expenses claimed with other expenses, and just the income and the foreign tax suffered on the foreign page. Thanks again Sam. Having now looked at the form though I'm perhaps even more confused as all the boxes seem to relate to income from savings, land and property. Also while the top of the form says fill in if the partnership had "any other income from sources outside the UK (except foreign income earned in the course of the partnership trade or profession - include this in the Partnership Trade and Professional Income pages, instead)." I thought that this describes my income? Sorry to be a nuisance! Hi Graham You are not being a nuisance at all and I do apologise you are correct regarding the SA802 - it is entered into the partnership main return, but I have no idea how you get the tax credit suffered, so I shall opt out and let another expert help you OK. Thanks for your time Sam. Do I have to contact another expert or does that happen automatically? This should happen automatically (but if you respond to this response asking for another expert to assist then this will put the question back on the board) Sam has suggested that I ask for another expert to assist with my question. Thanks. For the last 3 years I have been teaching for about 5 weeks each year in Italy employed by an Italian university. Up till now, I have claimed exemption from Italian income tax and declared the income approx 5200 euros) on my partnership tax return (nature of business: statistical consultancy). The University pay me a lump sum of around 5200 euros at the end of my contract and I subtract from this expenses (all receipted) for travelling to Italy and back and for part of my accommodation while I am there. I have then paid income tax on the net profit. I have now been told that this year (after I finished my teaching) the University will deduct Italian income tax (30%) before sending me the balance and there seems no mechanism for claiming expenses. Presumably I won't have to pay UK income tax on the balance but can I still claim these expenses against my UK income tax liability on the partnership tax return? Update A previous expert on this site helped as far as she could then pulled out as she wasn’t sure how to proceed with the detail. My understanding now raises two questions: 1. The Partnership Foreign supplementary page (SA802) says at the top of the form that I should fill in SA802 if the partnership had: "any other income from sources outside the UK (except foreign income earned in the course of the partnership trade or profession - include this in the Partnership Trade and Professional Income pages, instead)." So as this is income from my trade or profession, I should enter it on the pages suggested. But where? I intend to add it into the turnover figure at 3.24 with my travelling and accommodation expenses included in 3.25 on the Short Partnership return. Is that right? 2. What to do about the income tax (at 30%) already deducted by the University in Italy? Looking at HMRC’s Foreign Notes for SA106 (individual taxation) it says on page FN3: “If your overseas income and gains have had foreign tax deducted it may be possible to obtain relief from double taxation. Foreign Tax Credit Relief is normally the best way to obtain such relief, but if you do not want to or cannot claim it, you can deduct the foreign tax when calculating the amount of income and gains chargeable to UK tax. You cannot do both.” So by analogy, as I don’t want to claim the Foreign Tax Credit Relief, I intend to deduct the Italian tax from this income before adding it into 3.24. Is that right? I’m hoping the answers are yes and yes! If not, how should I proceed (with as little fuss as possible!) Many thanks. Hi Nicola Yes I'll wait a bit longer so please try to get another expert to help. I think though I need to amend the question as I think my suggestion in update 2 above would result in me paying tax twice. So I guess I must apply for foreign tax credit relief. The question then is, how do I do this on the short partnership form? Could you please add this to my question? Or would it be easier to cancel the original question and start again with an edited one?
http://www.justanswer.co.uk/tax/7xswj-last-years-teaching-weeks.html
CC-MAIN-2017-39
refinedweb
996
66.67
Date: Fri, 25 Jun 1999 12:14:38 -0400 (EDT) From: Alexander Viro <viro@math.psu.edu> Notice that there is a difference between the attributes affecting the VFS behaviour (append-only, etc.) and ones the VFS (or even kernel) doesn't care of (no-dump, etc.). For the latter we probably want to pass the raw attributes to the fs and let it figure out what it wants. For the former the common representation is needed. So we want a way to deal with raw and generic attributes.The interface for filesystem-specific attributes needs to be carefullythought out. Right now, how is a an application supposed to figure outwhich filesystem a particular file is being stored as? The onlysolution is to stat the file, and then grovel through /etc/mtab statingeach of the devices in /etc/mtab and matching against the device numberfound in the stat information.This is not a new problem; ext2's chattr simply blindly tries anext2-specific ioctl, and assumes that some other if a file belongs toanother filesystem, the ioctl will either not exist and EINVAL will getreturned, or the ioctl will do something vaguely rational on thatalternate system.But if the assumption is that many filesystems will be supporting thisinterface, I would change the "int is_raw" parameter to be "intattr_namespace", where 0 is the generic attribute name space, and otherfilesystems can support attributes in one or more assigned attributename spaces. If a filesystem doesn't support a particular attributenamespace, it can simply return an error.So I would suggest the following: (with similar function signatures forthe 'l' and 'f' variants):chflags(char *name, int attr_namespace, int *new_flags, int *curr_flags)If new_flags is non-NULL, then it is a pointer to the new flags whichshould be assigned to the file. If curr_flags is non-NULL, then it is apointer to the flags *after* the chflags operation. This makes it easyfor an application to check whether or not the filesystem refused to seta particular flag (for example, if it doesn't support that particularflag). - Ted-To unsubscribe from this list: send the line "unsubscribe linux-kernel" inthe body of a message to majordomo@vger.rutgers.eduPlease read the FAQ at
https://lkml.org/lkml/1999/6/25/147
CC-MAIN-2015-22
refinedweb
366
51.38
We use Trend Micro, Spiceworks reports that we have 115 computers/servers. The Security Center is reporting our antivirus multiple times and one will report 133 computers up to date and the other says 107 unknown status. We have no issues with scanning the machines as we use a DA account to do it. Any suggestions? Does it pull from the AV management console or from the PC's? 5 Replies Jan 5, 2011 at 11:35 UTC We use Trend Micro Officescan. For us, the Spiceworks Security Center reports similar to what you've described. That's because SW gets some information through WMI - client computers and their up-to-date status, and some information through a scan of the registry - which gets marked as unknown status. The difference in the numbers is the number of server OS, since windows server OS does not have the AntiVirusProduct namespace to report back through WMI. Jan 5, 2011 at 11:41 UTC Pittsburgh Computer Solutions is an IT service provider. That would explain the Servers not showing up. However, not the reason that some computers are reported twice. Also, when I open the Up to Date which Reads 133, it shows only 98 computers. Jan 5, 2011 at 2:19 UTC Spiceworks gets the AV up-to-date information through WMI from the windows Security Center. If that is not reporting the AV installations correctly, then that could be a reson for the count to be off. If there are multiple installs being reported through WMI, this link might help: http:/ Jan 13, 2011 at 2:26 UTC Pittsburgh Computer Solutions is an IT service provider. That appears to be for vista, we run an XP shop. Jan 13, 2011 at 2:48 UTC Wbemtest works on XP as well. My SW server is XP and I can get as far as calling up the AntiVirusProduct.instanceGuid entry with the same instructions.
https://community.spiceworks.com/topic/123683-the-security-center-on-the-dashboard
CC-MAIN-2016-44
refinedweb
321
71.95
Victor Duvanenko is an IC design engineer. He has worked on several graphics chips at Intel. Presently he is a consultant at Silicon Engineering Inc. in Santa Cruz. He can be reached at 1040 S. Winchester Blvd., #11, San Jose, CA 95128. Image compilation is a unique method of image compression whereby an image is transformed into a graphics coprocessor instruction stream. Even a simple implementation of the image compilation technique has lead to a 2.5:1 compression ratio with a corresponding reduction in the image reconstruction time. At present, resolutions for graphics displays vary from 320 x 200 on the very low-end to 2K x 2K on the highend, with 640 x 480 being fairly common. A 640 x 480 display consists of 307,200 pixels. If the depth is 8 bits per pixel (a byte for each dot on the screen), then it takes 307,200 bytes to define a full screen image. This is a considerable amount of data to move or manipulate interactively. Considering that resolution of raster displays is increasing every year, the job of graphic data manipulation will not get any easier. To put into perspective what it means to manipulate large amounts of data, consider that to transmit 307,200 bytes of data would take 43 minutes over a 1200-baud modem and about five minutes over a 9600-baud modem. At 9600 baud, you could not manipulate an image interactively. While you could manipulate text, it would be impractical to manipulate high-resolution bitmaps. With high-resolution color scanners rapidly becoming an inexpensive reality, interactive image manipulation will be a necessity. With applications such as large graphics databases, any compression is welcome. With other applications (such as interactive graphics systems) bitmap reconstruction time is of paramount importance. Consequently, any reduction in bitmap size would directly translate into improvement of response time. You can reduce transmission time to enable more efficient graphics data manipulation by using the following methods: One such graphics engine is the Intel 82786, a chip that contains many graphics instructions/primitives embedded in hardware. The 82786 also provides a 40-Mbyte/second bandwidth to graphics memory (a power that will be discussed later). The programs described in this article are designed to illustrate the specific advantages provided by a dedicated graphics coprocessor like the 82786. The image compilation code consists of two stand-alone programs one program for image compression and the other for image reconstruction. The compression is performed entirely by the microprocessor, which converts (compiles) an image/bitmap into a series of higher-level graphics instructions. The graphics program, not the bitmap, is stored on the hard disk. To reconstruct an image, the CPU loads the graphics program into graphics memory. The graphics coprocessor then executes the code and the bitmap is perfectly restored. Parallelism can be harvested for improved performance. The graphics program can be split into subprograms. As the CPU loads one subprogram, the graphics coprocessor can be executing another, thus reconstructing an image piece-by-piece in parallel. If this method of data compression is so great, you might ask, why isn't it being used more widely? Several reasons can be given for this. For one thing, inexpensive dedicated graphics hardware is relatively new. People are just beginning to appreciate the power and flexibility that these machines offer. The cost of these machines may still be prohibitive for some applications. Another reason is that compression takes time--the bigger and more complex the bitmap, the longer it takes. In some cases, this outweighs the gain. Yet another reason is that it takes time, money, and programming skills to refine and solidify compression algorithms. (It took two weeks to write the software in Listing One and Listing Two.) Finally, data compression does not work in all cases. Any general-purpose compression method must make some files longer (otherwise you could continually apply the method to produce an arbitrarily small file).<fn1> However, you could always apply the compression method, then see if the file gets smaller. If it does not get smaller, you could then stay with the original. Therefore, the resulting file is always less than or equal to, in size, to the original file. The Compression Program The compression program shown in Listing One, expects an 8-bit-per-pixel 640 x 480 bitmap to reside in graphics memory (graphics memory is mapped into part of system memory space). The only necessity is graphics memory accessibility to the CPU. The easiest (and most obvious) way to compile an image is to: This procedure would be repeated for all possible colors (in this case 0 through 255). The bitmap will be scanned as many times as there are possible colors. This could get out of hand with 2K x 2K 32-bit-per-pixel bitmaps. Even with 8 bits per pixel, scanning a 640 x 480 bitmap 256 times takes over an hour. The obvious way is usually not the best way. The next most obvious approach is to process only the colors that the bitmap contains. This requires an overhead of a single pass through the bitmap (one would have an array of flags that would be set, once a color was detected). This helps, but more can be done. Because the x and y coordinates are always known during the image scan, it is easy to find the maximum and minimum x and y coordinates for each color. A smaller region could be scanned during the compilation stage. This is exactly what the find_all_colors procedure of the compression program does. It scans through the bitmap once and establishes the region of color existence. A special structure color_struct, handles this. Each element in the structure contains the maximum and minimum x and y coordinates and the number of times that the color is detected during the scan. To make life easier, a type color_t of color_struct is defined. The next stage is to compile each of the regions of color, the extract_scan_lines procedure. Adding some initialization instructions is appropriate since you are making a graphics coprocessor instruction stream. Place a define color and a scan lines instruction (see sidebar for a discussion of the scan lines instruction) into a buffer. The array of scan lines will follow. Then proceed one scan line at a time, starting at minimum y and x coordinate for this color. The run-length encoding is quite simple: as the desired color is found, a flag is set. If the next pixel is of the same color, the count is incremented. If it is not of the same color, the end of the run has been reached and its length is stored in the buffer. This goes on, line-by-line of an image, until maximum y and x have been reached. This procedure is repeated for each color in the image. The graphics coprocessor instruction stream is stored in an array called buff. This array is several disk blocks in size. When it is filled, an end instruction is added and the array is written to a file on hard disk. The Loader Program The loader program, found in Listing Two expects a file to be in a specific format, which "compact" conforms to. This format consists of packets of data that are preceded by a header. The header describes the address in graphics memory where the data is to be placed and how many bytes of data are to be placed. The loader program performs some initialization tasks before loading the graphics coprocessor instructions into graphics memory. It waits for the graphics coprocessor to finish any instructions that may still be executing. It then loads the first packet of graphics instructions (scan lines) and directs the graphics coprocessor to execute them. While the graphics coprocessor is executing these instructions, the main processor gets another packet from the disk. This process continues until all packets have been loaded. The loader takes a time stamp before and after the loading process and reports the total time that it took to load and reconstruct the bitmap. Benchmark Results To further illustrate some of the performance advantages that a graphics coprocessor provides, Table 1, page 43, lists the test results. These tests were run on Intel's Xenix 311 system (which uses a 6-MHz 80286 microprocessor) with an 82786 add-in board (20 MHz with 1 Mbyte of graphics memory). All bitmaps were 640 x 480 at 8 bits per pixel. Bitmaps 1 - 3 are of Mandelbrot fractals. Bitmap 1, which consists of a straight uncompressed bitmap, is the control. Bitmap 4, a solid, single color bitmap, illustrates the best case. Table 1: Test results of image compilation routines Compression Compression Reconstruction File Compression Method Time Time Size Ratio Bitmap 1 none n/a 3.5 sec 307K 1:1 Bitmap 2 scan lines 612 sec. 1.3 sec. 120K 2.5:1 Bitmap 3 scan lines 613 sec. 1.3 sec. 121K 2.5:1 Bitmap 4 scan lines 11 sec. 0.02 sec. 2.9K 105:1 After reviewing the test results for bitmaps shown in Table 1, you may think that 10 minutes is an excessive price to pay for a 2 1/2 times reduction in size and reconstruction time. It is for some applications. For other applications, it allows them to place 2 1/2 times more information on the storage medium to present 2 1/2 times the amount of data to the user in a given amount of time or to retrieve images 2 1/2 times faster. This could make or break an application. Effectively, an 8-bits-per-pixel bitmap has been reduced down to about 3-bits per pixel, without losing any information. Some of the routines developed are useful for digital image processing. For example, find_all_colors routine generates a profile of the bitmap by quoting the number of times a color appeared in the bitmap. This could be turned into the probability density quote by dividing that count by the total number of pixels in the bitmap. This could be taken one step farther. Based on the probability density quote of a color, you could decide that the color is rare in a bitmap and is not worth processing. This could reduce the compression time as well as compressing the file, at a cost of losing some information. Using this method, you could minimize the picture content that is lost. In any case, the compaction algorithm speed could be improved (about three times by my estimates). If you used a 20-MHz 80386, the compression time would dip to less than a minute. Conclusion This image compilation technique offers infinite avenues for further exploration. This article has explored only a single instruction. Other instructions (bit_blit, for example) offer other possibilities. The graphics coprocessors that are presently available have a great variety of instructions, and this method of image compilation can lead to an adaptive image compression. It is possible to predict whether an image can be compressed by using run-length encoding. An average length of a run can be calculated for an image. If the average run takes up more space than one scan lines array element (dx, dy, and length use 6 bytes) then run-length encoding is worthwhile. For example, at 8 bits (one byte) per pixel, the average run for an image must be greater than 6 pixels. This is the break-even point for a compression technique. The compression ratio can be improved by removing redundancy from the compressed file. This can be accomplished by encoding repetitive scan lines sequences in the 82786 macros/subroutines. This achieves a two-dimensional compression. Another method is to reduce the number of bits used for dx, dy, and length elements in the scan lines array by scanning through the array and determining the maximum values ever used. This would require extra processing by the CPU, which would increase encoding and reconstruction time. A differential encoding technique could also be used to encode the differences between successive dx, dy, and length values.<fn2> This also requires some extra CPU processing. By using combinations of these techniques, you could increase compression ratios to above 10:1. The penalty of added CPU processing time may still outweigh the benefit of reduced I/O time caused by improved compression. Compression techniques are still in the infancy, and many promising techniques are emerging, such as "Chaotic Compression" (see Computer Graphics World, November 1987) promises a 10,000:1 compression ratio. References 2. 82786 Graphics Coprocessor User's Manual. Intel, 1987. The Scan Lines Instruction and Run-Length Encoding One of the most powerful 82786 instructions is scan lines, which is used to draw a series of horizontal lines. It is the fastest 82786 drawing instruction, executing at up to 2.5 million pixels per second, at 8 bits per pixel (faster at lower pixel depths). This instruction is generally used for area fills, and has pattern capabilities. The scan lines instruction looks like this: 1. the instruction itself, 16 bits (0BA00H); 2. the address of the scan lines array, a 32-bit value, low word followed by the high word; and 3. the number of horizontal lines to be drawn. The scan lines array elements have a particular format, consisting of: 1. dx, an offset from the beginning of the previous line in the x direction (16 bits, negative or positive); 2. dy, an offset from the beginning of the previous line in the y direction (16 bits, negative or positive); and 3. the length of the line (16 bits, negative or positive). The scan lines instruction starts at the present graphics location, adds dx and dy values of the first array element to it, and draws a line of the specified length. The graphics location is left at the beginning of the line. The new graphics location is then adjusted by dx and dy values of the second array element. The second line is then drawn. This process is repeated until the specified number of lines have been drawn. You could thus draw a scan line at the bottom of the screen and then one at the top of the screen, all within the same scan lines array. Areas of any shape can be drawn by using the scan lines instruction, and they do not have to be contiguous. You can jump to any position on the screen and continue drawing at any time, all with a single array (as long as the color and the pattern can remain constant). You can break up an image into areas of constant color and use a single scan lines array to describe each of them (one for black, one for white, one for a shade of green, and so forth). It would take as many scan lines arrays as there are colors in an image to completely describe that image. The scan lines instruction closely resembles run-length encoding. Run-length encoding removes redundancy from a data file by replacing data elements with the count followed by the element itself. For example, a sequence of AAAAAA can be replaced with 6A, resulting in 3:1 compression. The same technique can be applied to images. A sequence of six black pixels can be replaced by the number 60 (where 6 is the count and 0 is the color black). For an area of constant color, specifying the color along with every run is redundant. You can specify the offset from the current graphical location followed by the run-length. This should begin to resemble the scan lines definition--dx, dy, and length. For many images, encoding areas in this fashion is an efficient way of removing redundancy, thereby compressing an image. The less space an image takes, the faster it can be transmitted or retrieved from storage. _IMAGE COMPRESSION VIA COMPILATION_ by Victor J. Duvanenko [LISTING ONE] <a name="01f9_000c"> /* Bitmap compaction program. */ /* Converts bitmaps in 82786 graphics memory to Graphics processor instruc- */ /* tions. Simulates run length encoding, causing data compression for most */ /* bitmaps. Compression of an 8 bits per pixel down to 3 bits per pixel is */ /* not uncommon. */ /* Created by Victor J. Duvanenko */ /* Usage: compact output_file_name */ /* Input: */ /* An 82786 eight bits per pixel bitmap at address of 0x10000 (this */ /* can be easily changed). The bitmap is 640 pixels wide and 480 */ /* pixels heigh (this can also be changed). This was done for the */ /* simplicity of this example. */ /* Output: */ /* Binary file in the following) define color instruction */ /* 2) scan line instruction */ /* 3) link instruction (link around the array) */ /* 4) scan line array */ /* Caution: The loader must add a 'stop' instruction to the data */ /* (a NOP instruction with GCL bit set). See loader source */ /* code for example. */ /* */ /* This program was written for the XENIX environment, but can be easily */ /* and quickly ported to the PC. Just concentrate on the ideas and not on */ /* the implementation specifics. I'll try to point out XENIX specific sec- */ /* tions. */ #include<stdio.h> #include<fcntl.h> #include<sys/param.h> #include "/usr/tls786/h/tls786.h" #include "/usr/tls786/h/tv1786.h" #defineMAX_NUM_COLORS 256 /* maximum number of colors */ #define GP_BUFF_SIZE 8192 /* GP instruction buffer size */ #define BITMAP_WIDTH 640 #define TRUE 1 #define FALSE 0 #define OK TRUE /* return status for procedures */ #define PMODE 0644 /* protection mode of the output file */ #define MOVSW_ON TRUE /* enable 'move strings' in XENIX driver */ #define DEBUG FALSE /* top debug level - a fun one to turn on */ #define DEBUG_1 FALSE /* next debug level deeper */ #define DEBUG_2 FALSE /* everything you'd ever care to trace */ /* Global data buffers - used by several routines */ unsigned int gp_buff[ GP_BUFF_SIZE ]; /* GP instruction buffer */ unsigned int buff[ GP_BUFF_SIZE ]; /* temporary storage buffer */ unsigned char line_buff[ BITMAP_WIDTH ]; /* line buffer */ /* line_buff should ideally be dynamically alocated to allow any */ /* bitmap width. Left as an excersize for a C hacker. */ int p6handle; /* XENIX file descriptor for the 82786 memory */ int bm_height = 480; /* bitmap height */ int bm_width = 640; /* bitmap width */ long bm_address = 0x10000L; /* bitmap address */ /* Description of each color, histogram, plus additional fields for added */ /* dramatic performance improvement (defines a window of color existance). */ /* Enable DEBUG to see time savings that result from this technique. */ struct color_struct { long count; /* number of times a color appears in the bitmap */ int begin_y, /* scan line where a color first appears */ end_y, /* scan line where a color last appears */ begin_x, /* x position where a color first appears */ end_x; /* x position where a color last appears */ }; typedef struct color_struct color_t; /* Array containing color information about a bitmap under analysis */ color_t colors[ MAX_NUM_COLORS ]; /*---------------------------------------------------------------------*/ /* The body of the data compression program. */ /*---------------------------------------------------------------------*/ main(argc,argv) int argc; char *argv[]; { register i, index, j, num_colors; int n, value, x, y; int f1, f2, /* file descriptors */ buff_overflow; /* the following variables are for debug purposes only */ long average_begin_y, average_end_y; long average_begin_x, average_end_x; float percentage_y, percentage_x; color_t *clr_p; /* XENIX needed structures needed for movsw section of the driver */ union { struct tv1_cntrl brddata; byte rawdata[ sizeof( struct tv1_cntrl ) ]; struct io_data rdata; } regdata; /* Check the command line for proper syntax, a little */ if (argc < 2) { fprintf( stderr,"Usage is: %s output_file_name\n", argv[0] ); exit(1); } /* Open the file where compacted bitmap will be placed. If it doesn't */ /* exist create it. */ if (( f2 = open( argv[1], O_CREAT | O_WRONLY, PMODE )) == -1 ) { fprintf( stderr, "%s: Can't create %s.\n", argv[0], argv[1] ); exit(1); } /* XENIX specific functions to allow one to treat 82786 graphics memory */ /* as a file - a file descriptor gets passed to every routine that talks */ /* to the 82786. This allows a very flexible multiple 82786 environment. */ p6handle = open786( MASTER_786 ); if ( p6handle == NULL ) { fprintf( stderr, "%s: Can't access 82786.\n", argv[0] ); exit(1); } #if MOVSW_ON /* XENIX specific - enable movsw in the 82786 driver */ ioctl( p6handle, TEST_SFLAG, ®data ); if ( regdata.rdata.regval == FALSE ) ioctl( p6handle, SET_SFLAG, &value ); #endif /* Find all unique colors in the bitmap file. */ num_colors = find_all_colors( colors, bm_height ); #if DEBUG /* histogram and performance improvement information of the color */ /* existance window technique. */ printf( "num_colors = %d\n", num_colors ); average_begin_y = average_end_y = 0L; average_begin_x = average_end_x = 0L; for( i = 0; i < MAX_NUM_COLORS; i++ ) { clr_p = &colors[i]; /* for denser and cleaner notation purposes */ printf( "c %4d %7ld b_y%4d e_y%4d", i, clr_p->count, clr_p->begin_y, clr_p->end_y ); printf( " b_x%5d e_x%5d\n", clr_p->begin_x, clr_p->end_x ); /* average only the existing colors */ if ( clr_p->count != 0 ) { average_begin_y += (long)clr_p->begin_y; average_end_y += (long)clr_p->end_y; average_begin_x += (long)clr_p->begin_x; average_end_x += (long)clr_p->end_x; } } printf( "\n" ); average_begin_y /= (long)num_colors; average_end_y /= (long)num_colors; printf( "average Y begin = %ld\t\taverage Y end = %ld\n", average_begin_y, average_end_y ); percentage_y = ((float)( average_begin_y ) / bm_height * 100 ); percentage_y += ((float)((long)( bm_height ) - average_end_y ) / bm_height * 100 ); printf( "percentage Y savings = %2.2f\n", percentage_y ); average_begin_x /= (long)num_colors; average_end_x /= (long)num_colors; printf( "average X begin = %ld\t\taverage X end = %ld\n", average_begin_x, average_end_x ); percentage_x = ((float)( average_begin_x ) / bm_width * 100 ); percentage_x += ((float)((long)( bm_width ) - average_end_x ) / bm_width * 100 ); printf( "percentage X savings = %2.2f\n", percentage_x ); #endif /* Relying on the loader to execute a def_bitmap instruction before */ /* loading the GP instruction list generated by this program. */ /* Convert each color in the bitmap into scan lines - one color at a time */ for( i = index = 0; i < MAX_NUM_COLORS; i++ ) { if ( colors[i].count == 0L ) continue; /* skip non-existant colors */ buff_overflow = FALSE; n = extract_scan_lines((long)(index << 1),colors, i, buff, &buff_overflow); if ( buff_overflow ) { fprintf( stderr, "GP instruction list overflow.\n" ); exit( 1 ); } /* If the newly extracted scan lines array can't fit into the GP */ /* instruction buffer, store instruction built up so far, and */ /* start filling the buffer from the begining. */ if (( index + n ) > GP_BUFF_SIZE ) { /* Flag the user if a color generates more lines than there is */ /* space in the instruction buffer. Very unlikely. */ if ( index <= 0 ) { fprintf( stderr, "Instruction list overflow.\n" ); exit( 1 ); } /* store GP instruction built up so far */ write_buffer_to_file( f2, gp_buff, index ); /* adjust the addresses in the GP instruction set */ /* since the GP code is not relocatable. */ index = 0; buff[ 4 ] = (int)(( 20L ) & 0xffffL ); /* scan line array address */ buff[ 5 ] = (int)(( 20L ) >> 16 ); buff[ 8 ] = (int)(( (long)( n << 1 )) & 0xffffL ); /* link address */ buff[ 9 ] = (int)(( (long)( n << 1 )) >> 16); } /* copy elements from temporary buffer into instruction buffer */ for ( j = 0; j < n; ) gp_buff[ index++ ] = buff[ j++ ]; #if DEBUG printf( "index = %d\n", index ); #endif } /* store whatever is left in the very last buffer */ if ( index > 0 ) write_buffer_to_file( f2, gp_buff, index ); #if MOVSW_ON /* XENIX specific - disable movesw in the 82786 driver */ if ( regdata.rdata.regval == FALSE ) ioctl( p6handle, CLEAR_SFLAG, &value ); #endif return( 0 ); /* DONE!!! Wasn't that simple?! */ } /*-------------------------------------------------------------------------*/ /* Scan through the bitmap once and fill the 'colors' array with some */ /* very useful data about each color - how many times it apears in the */ /* bitmap and where in the bitmap it resides (define a window of existance */ /* for each color. Return number of colors that were found in the bitmap. */ /*-------------------------------------------------------------------------*/ find_all_colors( colors, num_lines ) color_t colors[]; /* array of colors - 256 elements */ int num_lines; /* number of lines in the bitmap */ { register int x; /* x coordinate on a scan line */ register color_t *color_ptr; /* pointer - for speed */ register int n; /* number of bytes in a scan line */ int line, /* present scan line in the bitmap */ num_colors; /* number of colors found in the bitmap */ #if DEBUG_1 printf("Entered find_all_colors routine. num_lines = %d\n", num_lines ); #endif /* Initialize the 'colors' array. */ for( x = 0; x < MAX_NUM_COLORS; ) { color_ptr = &colors[x++]; /* use a pointer for speed */ color_ptr->count = 0L; color_ptr->begin_y = color_ptr->end_y = 0; color_ptr->begin_x = color_ptr->end_x = 0; } /* Scan and analyze the bitmap one line at a time. */ for ( line = 0; line < num_lines; line++ ) { n = get_scan_line( bm_address, line_buff, line, bm_width ); for( x = 0; x < n; x++ ) { color_ptr = &( colors[ line_buff[x] ]); /* mark the begining scan line for this color */ if ( color_ptr->count++ == 0L ) { color_ptr->begin_y = line; color_ptr->begin_x = x; } /* adjust the ending scan line each time a color is detected */ color_ptr->end_y = line; /* adjust x window for a color if needed */ if ( x < color_ptr->begin_x ) color_ptr->begin_x = x; if ( x > color_ptr->end_x ) color_ptr->end_x = x; } } for ( x = num_colors = 0; x < MAX_NUM_COLORS; ) if ( colors[x++].count > 0L ) num_colors++; #if DEBUG_1 printf( "Exited find_all_colors routine.\n" ); #endif return( num_colors ); } /*-------------------------------------------------------------------------*/ /* The heart of compression. */ /* Procedure to extract scan lines from a bitmap file (with some help from */ /* 'colors' array). Assumes that the GP buffer is impossible to overrun */ /* (left as an exercise to correct). The best way to understand this one */ /* is to go through it with a particular bitmap in mind. */ /*-------------------------------------------------------------------------*/ extract_scan_lines( start_addr, colors, color, buff, overflow ) long start_addr; /* starting address of this GP instruction list */ color_t colors[]; /* colors description array */ int color, /* color that is being extracted */ buff[], /* gp instruction buffer */ overflow; /* overflow flag, gets set if the instruction buffer end */ /* is reached = ( num_elements - GP_BUFF_THRESHOLD ) */ { /* Keep x and y coordinates from call to call - needed to calculate */ /* dx and dy of the next scan line array. */ static int x = 0, /* present x coordinate */ y = 0; /* present y coordinate */ register i, count, line; int index, dy; /* gp instruction buffer index */ int n, num_lines, num_lines_index, first_time; int link_lower, link_upper; BOOLEAN within_scan_line; #if DEBUG printf( "color = %d\n",color ); #endif /* Start at the begining of a buffer and add the GP instructions */ /* to define color, scan lines, and link (around the array). */ /* Relies on the loader to def_bitmap, texture, and raster operation. */ index = 0; /* def_color instruction */ buff[ index++ ] = 0x3d00; buff[ index++ ] = (((int)color ) | (((int)color ) << 8)); buff[ index++ ] = 0; /* scan_lines instruction */ buff[ index++ ] = 0xba00; buff[ index++ ] = (int)(( start_addr + 20L ) & 0xffffL ); buff[ index++ ] = (int)(( start_addr + 20L ) >> 16 ); num_lines_index = index++; /* number of lines in the scan lines */ /* array is not yet known. */ /* link instruction - jump around the array */ buff[ index++ ] = 0x0200; link_lower = index++; /* fill in when the number of elements is */ link_upper = index++; /* known. */ num_lines = 0; first_time = TRUE; /* start at the bottom of the window (of this color) */ /* and process one line at a time until the top of the window. */ dy = line = colors[ color ].begin_y; for ( ; line <= colors[ color ].end_y; line++ ) { n = get_scan_line( bm_address, line_buff, line, bm_width ); count = 0; within_scan_line = FALSE; /* Process the line one pixel at a time */ n = colors[ color ].end_x; for( i = colors[ color ].begin_x; i <= n; i++ ) { if ( line_buff[i] != color ) { /* found a pixel that is not of desired color */ if ( within_scan_line ) { /* reached the end of scan line of desired color */ buff[ index++ ] = --count; /* length of it */ within_scan_line = FALSE; y += dy; count = dy = 0; num_lines++; } continue; /* to the next pixel */ } else /* found a pixel of desired color */ { if ( ! within_scan_line ) /* found the begining */ { buff[ index++ ] = i - x; /* dx for scan line instruction */ x = i; if ( first_time ) { /* first time for this color */ #if DEBUG_2 printf( "first time, y = %d, dy = %d\n", y, dy ); #endif buff[ index++ ] = dy - y; /* dy for scan line */ y = dy; dy = 0; /* reset dy, now that we've moved */ first_time = FALSE; } else buff[ index++ ] = dy; /* dy for scan line instr. */ within_scan_line = TRUE; /* signal the begining edge */ } count++; /* Take care of the last pixel == color case */ if ( i == n ) { buff[ index++ ] = --count; within_scan_line = FALSE; y += dy; count = dy = 0; num_lines++; } } } #if DEBUG_1 printf( "x = %d,\t y = %d\n", x, y ); #endif dy++; } /* Now, the number of lines of this color is known. */ /* Therefore, scan line array instruction and link address can be filled.*/ buff[ num_lines_index ] = num_lines; buff[ link_lower ] = (int)(( start_addr + (long)( index << 1)) & 0xffffL ); buff[ link_upper ] = (int)(( start_addr + (long)( index << 1)) >> 16); #if DEBUG_2 printf( "num_lines = %d,\tx = %d,\t y = %d\n", num_lines, x, y ); #endif return( index ); } /*--------------------------------------------------------------*/ /* Procedure that writes the GP instruction list to a file. */ /* An appropriate header is added before the GP list. */ /*--------------------------------------------------------------*/ write_buffer_to_file( fd, buff, num_of_elements ) int fd, /* output file descriptor */ buff[], /* pointer to the buffer */ num_of_elements; /* number of elements to be written */ /* each element is 16 bits (integer) */ { /* Header - placed before every block (8 bytes) */ struct header { int type; /* 0 - GP instructions, 1 - bitmap */ long addr; /* load address, ffffffff - don't care */ int num_bytes; /* number of bytes */ }; typedef struct header header_t; header_t hdr; /* Write the header into the file */ hdr.type = 0; hdr.addr = 0L; /* tell the loader to place instructions */ /* address 0 in 82786 memory. */ hdr.num_bytes = num_of_elements << 1; /* Write the header into the output file */ if ( write( fd, &hdr, sizeof( hdr )) != sizeof( hdr )) { fprintf( stderr, "compact: Write error.\n" ); exit(1); } /* Write the GP instruction list into the output file */ if ( write( fd, buff, num_of_elements << 1 ) != ( num_of_elements << 1 )) { fprintf( stderr, "compact: Write error.\n" ); exit(1); } return( OK ); } /*--------------------------------------------------------------------*/ /* Procedure to read any scan line from the bitmap stored in graphics */ /* memory. Swap bytes to make scanning easier. */ /*--------------------------------------------------------------------*/ get_scan_line( base_addr, buff_gsl, line, line_width ) long base_addr; /* starting address of the bitmap */ unsigned char *buff_gsl; /* scan line buffer */ int line, /* which line to read */ line_width; /* how many pixels in a line */ { long address; #if DEBUG_1 printf( "Entered get_scan_line routine. addr = %lx", addr ); printf( "\tline = %d\tline_width = %d\n", line, line_width ); #endif address = base_addr + ((long)( line ) * (long)( line_width )); getmem( p6handle, address, buff_gsl, line_width >> 1 ); swab( buff_gsl, buff_gsl, line_width ); /* be carefull with swab (note that source and destination are the same) */ /* functionality depends on implementation of the swab routine. */ #if DEBUG_1 printf("Exited get_scan_line routine.\n"); #endif return( line_width ); } <a name="01f9_000d"><a name="01f9_000d"> <a name="01f9_000e">[LISTING TWO] <a name="01f9_000e"> /* A simple GP instruction list loader. */ /* Created by Victor J. Duvanenko */ /* */ /* Loads a GP instruction list from a file into 82786 memory and instructs */ /* the GP to execute them. If the file contains more instructions they are */ /* read in. The loader then waits for the GP to finish the previous list. */ /* Only when the GP is finished does the loader place the new list in 82786 */ /* memory. */ /* */ /* Usage: load file_name */ /* */ /* Input: Binary file of the followind) GP instruction list. */ /* */ /* Output: GP instructions are loaded into 82786 memory. */ /* */ /* The loader provides the following services (may harm some applications) */ /* 1) def_bitmap, def_texture, and raster_op instructions with certain */ /* defaults are executed before loading the GP instruction list. */ /* 2) "stop" instruction is placed at the end of every GP list - 'nop' with */ /* GCL bit set. */ /* 3) Load time quote in milliseconds. */ #include<stdio.h> #include<fcntl.h> #include<sys/types.h> #include<sys/timeb.h> #include "/usr/tls786/h/tls786.h" #include "/usr/tls786/h/tv1786.h" #define BUFF_SIZE 32600 #define BOOLEAN int #define TRUE 1 #define FALSE 0 #define OK 1 #define INTERVAL 1 /* Sampling period in milliseconds */ #define WAIT 5000 /* wait period for the GP or DP to finish */ #define COMM_BUF_BOTTOM 0L #define DEBUG FALSE #define DEBG_1 FALSE /* GP instruction list buffer */ unsigned char buff[ BUFF_SIZE ]; main(argc,argv) int argc; char *argv[]; { register i; int p6handle, f1, n_items, ellapsed_time, value; struct timeb time_before, time_after; long addr, addr_bm; /* bitmap base address */ /* Header - placed before every block (8 bytes) */ struct header { int type; /* 0 - GP instructions, 1 - Bitmap */ long addr; /* load address, ffffffff - don't care */ int num_bytes; /* number of bytes */ }; typedef struct header header_t; header_t hdr; /* XENIX specific - turns on movsw instruction */ union { struct tv1_cntrl brddata; byte rawdata[ sizeof( struct tv1_cntrl )]; struct io_data rdata; }regdata; /* Check command line for proper usage - just a little. */ if (argc == 1) { fprintf( stderr, "Usage is: %s file_name\n", argv[0] ); exit(1); } /* Open the input file for reading only. */ if (( f1 = open( argv[1], O_RDONLY )) == -1 ) { fprintf( stderr, "%s: Can't open %s.\n", argv[0], argv[1] ); exit(1); } /* XENIX specific - enable the 82786 driver. */ p6handle = open786( MASTER_786 ); if ( p6handle == NULL ) { fprintf( stderr, "%s: Can't access 82786.\n", argv[0] ); exit(1); } /* XENIX specific - enable the use of movsw instruction driver. */ value = 0; ioctl( p6handle, TEST_SFLAG, ®data ); if ( regdata.rdata.regval == FALSE ) ioctl( p6handle, SET_SFLAG, &value ); addr = 0L; addr_bm = 0x10000L; ftime( &time_before ); /* Get present time stamp */ /* A bit of overhead to make sure that the bitmap and texture are defined */ /* before the GP command list is loaded. */ i = 0; buff[ i++ ] = 0x00; /* Def_bitmap */ buff[ i++ ] = 0x1a; buff[ i++ ] = 0x00; buff[ i++ ] = 0x00; buff[ i++ ] = 0x01; buff[ i++ ] = 0x00; buff[ i++ ] = 0x7f; /* 640 (for now) */ buff[ i++ ] = 0x02; buff[ i++ ] = 0xdf; /* by 480 (for now) */ buff[ i++ ] = 0x01; buff[ i++ ] = 0x08; /* 8bpp (for now) */ buff[ i++ ] = 0x00; buff[ i++ ] = 0x00; /* Def_logical_op */ buff[ i++ ] = 0x41; buff[ i++ ] = 0xff; buff[ i++ ] = 0xff; buff[ i++ ] = 0x05; buff[ i++ ] = 0x00; buff[ i++ ] = 0x00; /* Def_texture */ buff[ i++ ] = 0x06; buff[ i++ ] = 0xff; buff[ i++ ] = 0xff; buff[ i++ ] = 0x01; /* stop */ buff[ i++ ] = 0x03; /* Wait for a previous GP command list to finish */ if ( waitgp( p6handle, INTERVAL, WAIT ) < 0 ) { printf("GP is hung!!!\n"); exit(1); } /* Place it in 786 graphics memory */ putmem( p6handle, addr, buff, i >> 1 ); /* Direct the GP to execute the command */ putreg( p6handle, GRP_GR1, (int)( addr & 0xffff )); putreg( p6handle, GRP_GR2, (int)( addr >> 16 )); putreg( p6handle, GRP_GR0, 0x200 ); /* Now, for the GP list from an input file. */ /* Read the header and then the data. */ while (( n_items = read( f1, &hdr, sizeof( hdr ))) > 0 ) { i = 0; if ( n_items != sizeof( hdr )) { printf( stderr, "%s: Read error.\n", argv[0] ); exit(1); } /* does it matter where the GP list is placed? */ if ( hdr.addr != 0xffffffffL ) addr = hdr.addr; /* GP instruction list */ if ( hdr.type == 0 ) { if (( n_items = read( f1, buff, hdr.num_bytes )) == hdr.num_bytes ) { /* Add a "stop" command to the GP instruction list */ i += n_items; buff[ i++ ] = 0x01; buff[ i++ ] = 0x03; /* Wait for the GP to finish any previous instruction */ if ( waitgp( p6handle, INTERVAL, WAIT ) < 0 ) { fprintf( stderr, "GP is hung!!!\n" ); exit( 1 ); } /* Place it in 786 graphics memory */ putmem( p6handle, addr, buff, i >> 1 ); } else { printf( stderr, "%s: Read error.\n", argv[0] ); exit(1); } /* Direct the GP to execute the command */ putreg( p6handle, GRP_GR1, (int)( addr & 0xffff )); putreg( p6handle, GRP_GR2, (int)( addr >> 16 )); putreg( p6handle, GRP_GR0, 0x200 ); } /* Is it bitmaps - then place the data at that address */ if ( hdr.type == 1 ) { if (( n_items = read( f1, &buff[i], hdr.num_bytes )) == hdr.num_bytes ) { /* Place it in 786 graphics memory */ putmem( p6handle, addr_bm + hdr.addr, buff, n_items >> 1 ); } } } /* Get the time stamp after the loading is done. */ ftime( &time_after ); ellapsed_time = (int)( time_after.time - time_before.time ) * 1000; ellapsed_time += ( time_after.millitm - time_before.millitm ); printf( "%dms\n", ellapsed_time ); /* XENIX specific - disable movesw in the 786 driver */ if ( regdata.rdata.regval == FALSE ) ioctl( p6handle, CLEAR_SFLAG, &value ); return(0); } <pre>
http://www.drdobbs.com/database/image-compression-via-compilation/184408024
CC-MAIN-2015-11
refinedweb
5,651
52.29
Random Generator Picks the Indy 500 Winner Random Generator Picks the Indy 500 Winner Let's employs a previously covered tool—Random Generator—to pick the winner of the upcoming Indy 500 race, displaying probability and randomness in Java in action. Join the DZone community and get the full member experience.Join For Free Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat. With the qualifications completed and the field set for the 101st running of the "Greatest Spectacle in Racing," I thought it would be cool to see which driver would be picked by Random Generator to get the win for the 2017 Indy 500. Photo courtesy of Bryon J. Realey For those who are not aware of Random Generator, you can read my series of articles on DZone: Building a Random Generator Inside the Random Generator Advanced Options for Random Generator Introducing Random Generator to Maven Central Or, you can review the source code on GitLab. Setting Up the Data Since Random Generator can process a java.util.List object, I created a simple Participant object to house each car that qualified for the Indy 500. import lombok.Data; @Data public class Participant { private Integer startPosition; private Integer carNumber; private String driverName; private String odds; private Integer rating; } If you are not aware of Lombok, it is a great utility to keep from having to manually create getters, setters, and a few other boilerplate elements in POJOs. Giving Odds to The Drivers Like any race with established participants, odds are generated for those placing wagers on the competition. While I am not a gambling person, I did decide to use these odds to weigh the participants for the Indy 500 race. After all, the drivers in the race certainly have different skill sets and experience — which has proven to be helpful for the first 100 races held in Speedway, Indiana. According to SportsBook.ag, the drivers with the best odds are Helio Castroneves, Juan Pablo Montoya, Scott Dixon, and Tony Kanaan with 8:1 odds. The remainder of the field has odds that vary from 9:1 to unlisted. For those unlisted, I gave them odds of 99:1 to win the race. In order to translate the odds into a "rating" field that Random Generator can understand, I used the following logic: 100 - the antecedent (or left hand portion of the ratio) So, those with 8:1 odds were given a rating of 92 (100 - 8). When enabling the rating functionality in Random Generator, the rating field will be used to favor drivers with better odds of winning the race. For this experiment, I opted to use a rating level of 2 (RATING_LEVEL_MEDIUM). Random Generator in Action With the List<Participant> set, I was able to run Random Generator using the following line of code: List results = randomGenerator.randomize(participants, 33, 2); From there, I can use a simple System.out command to paint the order Random Generator believes will occur: System.out.println("\nRandom Generator Results:"); for (int i = 0; i < results.size(); i++) { System.out.println((i + 1) + ". " + results.get(i).getDriverName() + " (" + results.get(i).getCarNumber() + ") {Odds = " + results.get(i).getOdds() + "}"); } My results provided the following finishing order for the 101st running of the Indy 500 on May 28th, 2017: Random Generator Results: 1. Tony Kanaan (10) {Odds = 8/1} 2. Josef Newgarden (2) {Odds = 9/1} 3. Will Power (12) {Odds = 10/1} 4. Graham Rahal (15) {Odds = 25/1} 5. James Hinchcliffe (5) {Odds = 15/1} 6. Jack Harvey (50) {Odds = 50/1} 7. Juan Montoya (22) {Odds = 8/1} 8. Helio Castroneves (3) {Odds = 8/1} 9. Sebastien Bourdais (18) {Odds = 60/1} 10. Alexander Rossi (98) {Odds = 20/1} 11. Ryan Hunter-Reay (28) {Odds = 10/1} 12. Marco Andretti (27) {Odds = 10/1} 13. Carlos Munoz (14) {Odds = 18/1} 14. Simon Pagenaud (1) {Odds = 10/1} 15. Ed Carpenter (20) {Odds = 25/1} 16. Takuma Sato (26) {Odds = 25/1} 17. Scott Dixon (9) {Odds = 8/1} 18. Oriol Servia (16) {Odds = 80/1} 19. Charlie Kimball (83) {Odds = 25/1} 20. Fernando Alonso (29) {Odds = 15/1} 21. JR Hildebrand (9) {Odds = 20/1} 22. Jay Howard (77) {Odds = 99/1} 23. Mikhail Aleshin (7) {Odds = 80/1} 24. Max Chilton (8) {Odds = 60/1} 25. Pippa Mann (63) {Odds = 99/1} 26. Spencer Pigot (11) {Odds = 99/1} 27. Buddy Lazier (44) {Odds = 99/1} 28. Zach Veach (40) {Odds = 99/1} 29. Connor Daly (4) {Odds = 99/1} 30. Gabby Chaves (88) {Odds = 99/1} 31. Sebastian Saavedra (17) {Odds = 99/1} 32. Sage Karam (24) {Odds = 99/1} 33. Ed Jones (19) {Odds = 99/1} Have a really great day! Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat. Opinions expressed by DZone contributors are their own. {{ parent.title || parent.header.title}} {{ parent.tldr }} {{ parent.linkDescription }}{{ parent.urlSource.name }}
https://dzone.com/articles/random-generator-picks-the-indy-500-winner
CC-MAIN-2018-47
refinedweb
837
59.19
xpost from my personal blog As you may have seen from my last post I'm migrating things to Next.js and keep running into little issues, so I've decided to blog about them here. The newest issue I've run into has been sharing common TypeScript components between apps in a Lerna monorepo. My setup looks like this: packages/ frontend/ landing/ ui/ common/ backend/ What I've been trying to do it share a ui component between the frontend and landing projects. It's as simple as it sounds so I expected it to just work but there are some tricky gotchas. My landing page in this case is and my frontend is. Issues Cannot import outside of base directory This error message looking familiar? You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. The issue stems from the face that Next.js cannot import anything from outside its root, there are ways to change your tsconfig.json baseUrl but I couldn't get that way to work with Lerna. Multiple React versions Having issues with multiple versions of React? If this error is present in your application continue reading. hooks can only be called inside the body of a function component Having to compile .tsx files before importing The last issue I've been having is I needing to compile any .ts or .tsx files I want to import, however in a monorepo that's what I'm looking to do. Links If you've run into the problems above you may have found the following links: - - - - If any of these sound familiar you're in luck! I've managed to cobble together enough things to make it work. Solution Pin React version The first step is to settle on a React version you want to use in your monorepo. If you're using the latest Next.js it probably installed React 17, however my application is still on 16. Decide on one to use and update your package.json files accordingly. Transpile .ts and .tsx files Add this to your next.config.js to force Next.js to transpile your components: config.module.rules.push({ test: /\.tsx?|\.ts?$/, use: [options.defaultLoaders.babel], }); Resolve the correct React implementation Additionally to the above Webpack config, add this to your next.config.js file: config.resolve.alias['react'] = path.join( __dirname, '..', '..', 'node_modules', 'react' ); config.resolve.alias['react-dom'] = path.resolve( __dirname, '..', '..', 'node_modules', 'react-dom' ); We're going up two directories in this case because we want our root node_modules/ directory and my folder structure has everything under packages/. Hopefully that clears up any issues you were having! Next.js has some great features and generally works well but doing things like this is a bit finnicky, hopefully support is ironed out soon. Discussion (4) Did you find a workaround for the problem of That's probably because you're trying to import {} from '../../common/'; If you're using Lerna you need to let it bundle the raw .ts{x} files into your node_modules. Then do import {} from @project/common. I actually just did the same last night, happy to see someone covering it. Are you as nervous as I am about next-transpile-moduleschanging and not working in the future? Haha I guess I wasn't nervous because I hadn't thought about that. I'll have to update this blog post with my current setup because it's not exactly the same as what I described here anymore.
https://dev.to/alexbh/shared-components-in-a-lerna-typescript-next-js-project-5426
CC-MAIN-2021-21
refinedweb
591
66.23
Bundling Ajax into JSF components Any Java developer who has already worked with "">Java Server Faces has undoubtedly come across the need for a custom component. Most components in JSF implementations are rudimentary and don't really address real-world situations--if data-entry solutions for all problem domains were as simple as a login form, then JSF would be just the right tool out of the box. The saving grace of the framework is the ability to create and extend custom components, and if you couple that with the power and versatility of Ajax, you really start to reap the benefits of the modern Model-View-Controller architecture. Why JSF and Ajax? Ajax and JSF would on the surface seem to be two technologies that would be difficult to marry. Ajax processing is predominantly client-side, while JSF processing is predominantly server-side. Ajax is mostly JavaScript and JSF is Java. While very different, the two technologies can combine to create a powerful set of reusable user interface tools for developers. Let's look at an example. A developer is using JSF to create a form element that requires some specific input. This form element is just a simple input text field, but when the user tabs out of the field, an Ajax validation routine is triggered from the onblur event to test the validity of the typed data. The developer has to use this input field in many places in the application and has to embed the same JavaScript into the component on page every time it is used. Now what if all that code could be embedded into the component instead of the page? The page developer could continue to drop components onto the page and everything else would be taken care of. By shifting the validation processing into the component itself, we've made an extremely reusable, reliable component. The best benefit of this might be that we could also treat the tag as an interface and the implementation would be at the discretion of the tag developer. Any changes to the implementation would be transparent to the page developer. These benefits apply to all custom JSF components. Now let's take a look at how to get started creating some of our own. Creating a JSF Component from Scratch Creating a JSF component can be a bit of a challenge at first, due to the steps involved and the considerations of the "">JSF lifecycle. Knowing what is going on at a given time is extremely important if you are going to make the proper method calls when they are needed. Later on, we'll discuss a JSF PhaseListener that will allow processing during JSF lifecycle events. There are six events in the lifecycle. A deeper discussion of these events is beyond the scope of this article, but a detailed explanation of these events is located on Sun's "">Java Server Faces site. - Restore view. - Apply request values; process events. - Process validations; process events. - Update model values; process events. - Invoke application; process events. - Render response. Now that we've mentioned the lifecycle events, we'll continue creating our custom component. Creating a component from scratch involves four steps. Later on, we'll use these steps to create our first custom component. - Create a rendering class for your component. - Define the component in faces-config.xml. - Create a tag class for placing the component in a page. - Create the tag library definition in a .tld file. Extending Existing JSF Components The simplest way to create your own JSF component is to find an existing component that already takes care of most of the grunt work for you. For example, say you want a text field to be a calendar input, so you extend an existing component that renders an input field to do the job. Why go through all the trouble of creating your own from scratch when the largest portion of the rendering work is done for you in an existing component? Please note that the terms component and tag can be used interchangeably depending on the context. In this article, "component" refers the item we want to place on a page as a whole. For example, an input text field on a JSF page is a component. "Tag" refers to the tag class or tag placed on the page by the developer. The tag is what is responsible for placing and configuring our component. Also, note that the renderer is the class responsible for writing the component content. Let's look at a renderer example for extending an existing component. For this example, we are extending another renderer that creates a input text field. Remember that it doesn't really matter here which implementation of input text we are using because all implementations carry the same attributes as the JSF reference implementation, but most add more attributes for convenience or enhanced functionality. "">Apache MyFaces Tomahawk, for example, adds attributes for to handle the display of content based on the user's security role. [/prettify][/prettify] [prettify] public class MyHtmlInputTextRenderer extends HtmlInputTextRenderer public void encodeBegin(FacesContext context, UIComponent component) throws IOException { super.encodeBegin(context, component); //We could create any other component and share attribute values //from this tag to another component //Renderer baseRenderer = // context.getRenderKit().getRenderer("javax.faces.Form", "javax.faces.Form"); //baseRenderer.encodeBegin(context, component); } public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); // get properties from UIOutput that were set by the specific taghandler String myMessage = (String)component.getAttributes().get("myattributemessage"); writer.startElement("p", component); writer.writeText("myMessage"); writer.endElement("p"); writer.write("\n"); } //We could create any other component and share attribute values //from this tag to another component //Renderer baseRenderer = // context.getRenderKit().getRenderer("javax.faces.Form", "javax.faces.Form"); //baseRenderer.encodeEnd(context, component); super.encodeEnd(context, component); } There's a lot of potential here in this code. We could manipulate the existing component in any fashion we choose. Note that in the encodeEnd method, a call to get the property myattributemessage was retrieved and displayed to the user. By extending an existing component, we not only get all the existing attributes, but we can just add new ones in our .tld definition. In order to make extending existing components work, you've got to put all the pieces together. The renderer and tag classes should extend an existing tag and an existing component and you still need to create the component definition in the faces-config.xml and the tag library definition. Note, however, a painful limitation of the JSP tag library specification: if you extend an existing tag, you must create your own tag library definition for that component. The simplest thing to do is to find the .tld definition for the tag you are extending and copy that tag's definition into your own .tld, and then you are free to make modifications. This is cumbersome, especially when you are looking at extending a component that has 50 attributes. A useful future feature of creating tag libraries would be to give the developer the capability to extend another tag's definition through some XML element; this would bring the tenets of object-oriented programming into .tld files. Just be glad that you can pick up all 50 of those attributes by extending an existing tag class, or you might also have had to write all 50 getters and setters as well. Let's recap extending existing JSF components by laying out the steps involved in doing so. - Extend the rendering class for a component that is similar to the component you want to create. - Define the component in faces-config.xml. - Extend the tag class of the component you are mimicking. - Copy the original .tld definition for the component you are mimicking into your .tld file. Remember to change it to point to your subclass. Now that we know the steps to creating or extending our own JSF components, we can move on creating more advanced components using Ajax. Use a PhaseListener to Deliver Ajax Content A benefit of using faces is that you don't need to define servlets to deliver content to Ajax calls. A PhaseListener fires at each stage of the JSF lifecycle, letting you intercept a request and write to the response. Ajax data can be delivered in many ways, including XML, HTML, and JSON (JavaScript Object Notation). By far the simplest way to deliver content is JSON. JSON syntax is simpler to generate using json_simple.jar, it requires less bandwidth than XML, and doesn't require parsing by JavaScript on the client side like XML does. You'll need to download the source code from json.org and compile it yourself. More information about the JSON syntax can be found at the JSON home page. Let's take a look at an example of a PhaseListener and how it will deliver content to an XmlHttpRequest. [/prettify][/prettify] [prettify] import java.io.IOException; import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.json.*; import java.io.*; public class AjaxPhaseListener implements PhaseListener { public void afterPhase(PhaseEvent event) { String viewId = event.getFacesContext().getViewRoot().getViewId(); if (viewId.indexOf("Ajax") != -1) { handleAjaxRequest(event); } } private void handleAjaxRequest(PhaseEvent event) { FacesContext context = event.getFacesContext(); HttpServletResponse response = (HttpServletResponse) context .getExternalContext().getResponse(); Object object = context.getExternalContext().getRequest(); if (!(object instanceof HttpServletRequest)) { //Only handle HttpServletRequests return; } HttpServletRequest request = (HttpServletRequest) object; // actually render using JSON. try { JSONObject myMessage = new JSONObject(); myMessage.put("message", "I am sending a message"); response.setContentType("text/plain"); response.setHeader("Cache-Control", "no-cache"); response.getWriter().write(secureWrapJSON(myMessage)); event.getFacesContext().responseComplete(); } catch (Exception e) { e.printStackTrace(); } } public void beforePhase(PhaseEvent arg0) { //not used, but implemented to satisfy compiler } public PhaseId getPhaseId() { return PhaseId.RESTORE_VIEW; } } //Secure wrap the JSON to prevent hijacking public String secureWrapJSON(JSONObject json) { return "/*" + json + "*/"; } Don't forget to configure the PhaseListener in the faces-config.xml: com.oreilly.ajax.AjaxPhaseListener The PhaseListener checks the request to see if the view requested contains the word "Ajax." If it does, it delivers a message to the response in the form of JSON text. It is that simple. On the client side, this message can be read into a JavaScript object by calling eval on the responseText property of the parm of your callback method. JSON can be as complex and as structured as you want it to be. For the sake of this example, we just sent a one-line message. In reality, you will typically be sending much larger data. Below is the message you would see if you hit Ajax.faces with your browser. {"message":"I am sending a message"} This could just as easily have been XML being returned on the response, but then we would have to parse the XML with JavaScript, making a simple task fairly arduous. Creating Your Component and Embedding Your Ajax The reality of creating an Ajax-enabled JSF component is that it really isn't any different from creating any JSF component, except that the Ajax code is written in the renderer class. For the sake of simplicity, JavaScript functions should be included in a .js file. Don't attempt to write JavaScript inside the renderer directly. Below is the JavaScript to get the JSON message from our PhaseListener. [/prettify][/prettify] [prettify] function getMessage() { var url = "Ajax.faces";("Get", url, true); req.onreadystatechange = callback; req.setRequestHeader("content-type","text/plain"); req.send(null); } } function callback() { var jsonData = req.responseText; //omitted code for stripped secure JSON /* json */ var jsonObject = eval('(' + jsonData + ')'); var message = jsonObject.message; alert(message); } } The code is pretty straightforward as Ajax goes. Remember that Ajax is not some new language; it is just merely the concept of making an asynchronous call from JavaScript behind the scenes to get data. It doesn't really have to be any more complicated than that. The call to getMessage() will be embedded into our JSF component in the renderer so that it fires with a certain event; onblur(), for example. The getMessage() method will make a call to the Ajax.faces URL and get our JSON data, and the callback function will get the message text and send an alert. One thing to remember is that since the JavaScript function code will be included in a .js file, you should write the JavaScript call for the file into the renderer. Doing this will make the component more modular, but it will also create a redundancy if you have to include your component many times in one JSF page. Another solution would be to create an initializer tag that will write your JavaScript support classes into a page. Either way, it needs to be easy for page developers to use your component. [/prettify][/prettify] [prettify] public class MyRenderer extends Renderer public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.startElement("script", component); writer.writeAttribute("language", "text/javascript", null); writer.writeAttribute("src", "/js/ajax.js", null); writer.endElement("script"); writer.write("\n"); } } Another option to simplify matters would be to use an Ajax framework like Dojo or Prototype to ease the pain of writing all that boilerplate Ajax code. Let's take a look at what Dojo could do for us. First we need to include the dojo.js file into our component like we did above with our .js file. We still also need our .js file, because it will contain our callback function. Remember to write out the include for the dojo.js file before our file or our JavaScript will be useless. [/prettify][/prettify] [prettify] function getMessage(){ dojo.io.bind({ url: ajax.faces, sync: false, load: function (type, data, evt){ callback(data); }, error: function(type, error){ dojo.debug('Error getting JSON data:' + error.message); }, mimetype: "text/json-comment-filtered" }); } function callback(type, data, evt){ alert(data.message); } Now we have seriously cut back on some code. We are now using Dojo to hide all the nasty Ajax interactions for us. This will make our code much cleaner. Please make note that the code above is using the MIME type text/jason-comment-filtered. This will tell Dojo to expect the JSON to be commented and the framework will strip the sync is set to false. If you set this to true, the browser will lock until the call finishes. The default for this is always false. There are several informational ""> articles on the Web to get you started using Dojo and JSON. Let's take a look at the same article above written using Prototype. [/prettify][/prettify] [prettify] function getMessage(){ //NOTE: Prototype expects secure as /*-secure- {json} */ //NOTE: IF you send response.setHeader("X-JSON", jsonString) //from server, then AJAX will parse it into a JSON Object, protecting //your JSON from being exposed Ajax.Request({ url: ajax.faces, //parameters: method: 'get', onComplete: function (type, data, evt){ callback(data); }, mimetype: "application/X-JSON" }); } function callback(type, data, evt){ alert(data.message); } Looking At It from Above Now that we know what it takes to write a Ajax-enabled JSF component, let's recap with a set of clearly defined steps. - Decide whether you want a new JSF component or you want to extend an existing one and follow the steps for that process. - Create and configure a PhaseListenerto deliver Ajax content to the response. - Embed JavaScript includes into the renderer class' encodeBegin()method. - Embed your method call to trigger your Ajax method into the renderer or the tag class. We have all the tools necessary to create our own Ajax-enabled JSF components. We have also leveraged some open source tools to simplify the process. Make note that there are already many Ajax-enabled JSF components already out there and most are open source. The ability to create reusable dynamic web components is where the power in the coupling of JSF and Ajax lies. Resources - "">Ajax on Java by Steven Douglas Olson - Apache MyFaces - Dojo - Prototype - "">Tomahawk - JSON - Login or register to post comments - Printer-friendly version - 10884 reads
https://today.java.net/node/219775/atom/feed
CC-MAIN-2015-35
refinedweb
2,679
57.37
People think of automation to gradually reduce time-consuming repetitive and manual work. It is a known fact that automation testing reduces time, improves productivity, generates reports automatically, etc. Fundamentally one should have some level of expertise in coding to write automation test scripts and subsequently run it without any hassles, you need to have so many things handy while setting up a framework, say for instance you should have technical know-how of integrating necessary plugins, creating a proper folder structure for your code, selecting tools and IDE’s, etc. A newbie software tester with less coding knowledge will be overwhelmed with these setups and potentially neglect automation testing. We’ve seen a lot of testers, QA engineers using Postman/Insomnia/Paw to test their REST API endpoints manually because they do not know how to automate them. Automating API testing is a more complex procedure, setting the initial process and running it successfully is often one of the most challenging parts of the process, one must be ready to face a series of challenges like parameter validation, a sequence of API calls, testing the parameter combination, etc. Our engineers gave it a go with many API frameworks like RestAssured, SOAP UI, Katalon Studio and Karate. We have always been excited while working with Karate framework because Karate framework is promisingly a mature framework since API tests are written using plain text Gherkin style as it is built on top of Cucumber and is written in Java. Why we recommend it Java knowledge is not required and even non-programmers can write tests with ease ( it runs on JVM) It supports JSON and XML including JsonPath and XPath expressions, Re-use of payload-data and user-defined functions across tests is possible. Simple latency assertions can be used to validate non-functional requirements like performance requirements. (for ex. it is used to measure the performance of the API when it is executed multiple times by measuring the response time) How to Setup Karate framework Let us see the step by step guide on setting up Karate framework Start up your favorite IDE. (we are taking InteliJ IDEA in this example.) Go to File> New> Maven Project and take the defaults on the first screen. Under New Maven Project, click on Add Archetype Enter the following info: Archetype Group Id= com.intuit.karate Archetype ArtifactId= karate-archetype Archetype Version=0.9.4 Click Ok It should find Karate-archetype. Click on Next. Enter the ‘Groupid’ and ‘Artifactid’ for the project and click on Next. Select the maven version and click on Next Finish the Setup Now the default karate project will be created with the ‘Feature and config files’. Karate-config.js One has to check whether karate-config.js exist on the ‘classpath’. A ‘classpath’ is a place where the important configuration files are expected to be in place by default, karate-config.js contains JavaScript function which will return a JSON object. The values and keys in this JSON object are available as script variables. The below sample JavaScript will tell you how one can get the value of the current ‘environment’ or ‘profile’, and then set up ‘global’ variables and helps you to understand the Karate configuration.; } A Global variable can be initialized in the config file which can be used in the test feature file. Also based on the environment we can set the global URL from the config file. package animals.cats; import com.intuit.karate.junit4.Karate; import org.junit.BeforeClass; import org.junit.runner.RunWith; @RunWith(Karate.class) public class CatsRunner { @BeforeClass public static void before() { System.setProperty("karate.env", "e2e"); } } Testing the status code Let’s write a scenario that tests a GET endpoint and checks if it returns a 200 (OK) HTTP status code: Background: * url '' Scenario: get all users and then get the first user by id Given path 'dishes' When method get Then status 200 Here we have the common URL in the Background, in the given path ‘dishes’ will be the route to the URL. This works obviously with all possible HTTP status codes. Testing the Response Let’s write another scenario that tests that the REST endpoint returns a specific response: Scenario: Testing the exact response of a GET endpoint Given url '' When method GET Then status 200 And match $ == {id:"1234",name:"John Smith"} The match operation is used for the validation where ‘$’ represents the response. So the above scenario will check that the response exactly matches ‘{id:”1234?,name:”John Smith”}’. We can also check specifically for the value of the id field: And match $.id == "1234" Scenario: Testing that GET response contains specific field Given url '' When method GET Then status 200 And match $ contains {id:"1234"} Validating Response Values with Markers: At times, when we don’t know the exact value that is returned, we can still validate the value using markers — placeholders for matching fields in the response. Ex. Scenario: Test GET request exact response Given url '' When method GET Then status 200 And match $ == {id:"#notnull",name:"John Smith"} And match $ contains {id:”#notpresent”} Testing a POST Endpoint with a Request Body Let’s look at a final scenario that tests a POST endpoint and takes a request body: Scenario: Testing a POST endpoint with request body Given url '' And request { id: '1234' , name: 'John Smith'} When method POST Then status 200 And match $ contains {id:"#notnull"} Schema Validation: Karate provides a simpler, user-friendly and more powerful response validation using Json as a variable to validate the structure of a given payload. *' We have been using the Karate framework for quite some time now and this framework comes with a very rich set of useful features that enables you to perform Automated API Testing very easily and quickly. It eases the testing process by allowing script developers or testers without any programming knowledge to script the sequences of HTTP calls. We believe that through this tutorial you have gained a lot of useful insights and got a basic understanding of Karate‘s features. Please feel free to reach out for your API testing needs, we are glad to help. Submit a Comment
https://codoid.com/all-about-karate-framework/
CC-MAIN-2021-31
refinedweb
1,032
56.89
Social power, influence, and performance in the NBA, Part 1 Explore valuation and attendance using data science and machine learning Python, pandas, and a touch of R Content series: This content is part # of # in the series: Social power, influence, and performance in the NBA, Part 1 This content is part of the series:Social power, influence, and performance in the NBA, Part 1 Stay tuned for additional content in this series. Getting started In this tutorial series, learn how to analyze how social media affects the NBA using Python, pandas, Jupyter Notebooks, and a touch of R. Here in Part 1, learn the basics of data science and machine learning around the teams in the NBA. The players of the NBA are the subject of Part 2. What is data science, machine learning, and AI? There is a lot of confusion around the terms data science, machine learning, and artificial intelligence. Often used interchangeably, but from a high level: - Data science is a philosophy of thinking scientifically about data. - Machine learning is a technique in which computers learn without explicitly being instructed to learn. - Artificial intelligence is intelligence exhibited by machines. (Machine learning is one example of an AI technique; another example is optimization.) 80/20 machine learning in practice An overlooked part of machine learning is the 80/20 rule in which approximately 80 percent of the time is spent getting and manipulating the data, and 20 percent is devoted to the fun stuff like analyzing data, modeling the data, and coming up with predictions. Figure 1. 80/20 Machine learning in practice A problem of data manipulation that isn't obvious is getting the data in the first place. It is one thing to experiment with a publicly available data set; it is another entirely to scrape the internet, call APIs, and get the data in usable shape. Even beyond those issues, a problem that can be even more challenging is getting the data into production. Figure 2. Full-stack data science Rightfully so, a lot of attention is paid to machine learning and the skills required to model: applied math, domain expertise, and knowledge of tooling. To get a production machine-learning system deployed is a whole other matter. This is covered at a high level in this tutorial series with the hope that it will inspire you to create machine-learning models and deploy them into production. What is machine learning? Beyond a high-level description, there's a hierarchy to machine learning. At the top is supervised learning and unsupervised learning. There are two types of supervised learning techniques: classification problems and regression problems that have a training set with labeled data. An example of a supervised regression machine-learning problem is predicting future housing prices from historical sales data. An example of a supervised classification problem is using a historical repository of images to classify objects in images: cars, houses, shapes, etc. Unsupervised learning involves modeling where data is not labeled. The correct answer might not be known and needs to be discovered. A common example is clustering. An example of clustering is to find groups of NBA players with things in common and label those clusters manually — for example, top scorer, top rebounders, etc. Phrasing the problem: What is the relationship between social influence and the NBA? With the basics out of the way, it is time to dig in: - Does individual player performance affect a team's wins? - Does on-the-court performance correlate with social media influence? - Does engagement on social media correlate with popularity on Wikipedia? - Is follower count or engagement a better predictor of popularity on Wikipedia? - Does salary correlate with on-the-court performance? - Does salary correlate with social media performance? - Does winning bring more fans to games? - What drives the valuation of teams: attendance, local real estate market? To answer these questions and others, it is necessary to retrieve several categories of data: - Wikipedia popularity - Twitter engagement - Arena attendance - NBA performance data - NBA salary data Figure 3. NBA data sources Going deep into the 80-percent problem: Gathering data Gathering this data is a nontrivial software engineering problem. The first step to collecting all of the data is figuring out where to start. For this tutorial, a good place to start is to collect all the players from the NBA 2016-17 season. This brings up a helpful point about how to collect data: If it is easy to collect data manually — for example, download from a website and clean up the data manually in Excel — then this is a reasonable way to start with a data science problem. If collecting one data source and manually cleaning the data turns into more than a few hours, then it's probably best to write code to solve the problem. Fortunately, collecting the first data source is as simple as downloading a CSV from Basketball Reference. Now that the first data collection is out of the way, it's time to quickly explore what it looks like using pandas and Jupyter Notebook. Before you can run some code, you need to: - Create a virtual environment (based on Python 3.6) - Install the packages used in this tutorial: pandas and Jupyter Notebook. Because the pattern of installing packages and updating them, is so common I put it into a Makefile, as shown below: Listing 1. Makefile contents setup: mkdir -p ~/.socialpowernba && python3 -m venv ~/.socialpowernba install: pip install -r requirements.txt To start working on a project, run make setup && make install. Another trick is to create an alias so that when you want to work on a particular project, you automatically source the virtualenv when you cd into the project. The contents of the .zshrc file with this alias inside look like: alias nbatop="cd ~/src/socialpowernba && source ~/.socialpowernba/bin/activate" To start the virtual environment, type nbatop. You will cd into the checkout and start your virtualenv. To inspect the data set you downloaded or used from the GitHub repo: Start Jupyter Notebook: Jupyter notebook. Running this launches a web browser in which you can explore existing notebooks or create new ones. If you are using the files in the GitHub repo, look for basketball_reference.ipynb, which is a simple notebook that looks at the data inside. You can create your notebook using the menu on the web or load the notebook in the GitHub repo called basketball_reference. To perform an initial validation and exploration, load a CSV file into a pandas data frame. Loading a CSV file into pandas is easy, but there are two caveats: - The columns in the CSV file must have names. - The rows of each column are equal length. Listing 2 shows how to load the file into pandas. Listing 2. Jupyter Notebook basketball reference exploration import pandas as pd nba = pd.read_csv("../data/nba_2017_br.csv") nba.describe() The following image shows the result of the data loaded. The describe function on a pandas data frame provides descriptive statistics, including the number of columns. In your data, and shown below, the number of columns is 27, and the median (this is the 50-percent row) for each column. At this point, it might be a good idea to play around with the Jupyter Notebook you created and see what insight you can observe. To learn more about what pandas can do, see the official pandas tutorial page. Figure 4. NBA dataset load and describe One thing this data set doesn't have is a clear way to rank offensive and defensive performance of a player in one statistic. There are a few ways to rank players in the NBA using just one statistic. The website FiveThirtyEight has a CARMELO ranking system. ESPN has Real Plus-Minus, which includes a handy output of wins attributed to each player. The NBA's single-number statistic is called PIE (Player Impact Estimate). The difficulty level increases slightly when you get the data from both ESPN and the NBA websites. One approach is to scrape the website using a tool such as Scrapy. The approach used in this tutorial is a bit simpler than that, though. In this case, cutting and pasting from the website into Excel, manually cleaning up the data, then saving the data as a CSV is quicker than writing code to do it. Later, if this turns into a bigger project, this approach might not work as well. But for this tutorial, it's a great solution. A key takeaway for messy data science problems is to continue to make forward progress quickly without getting bogged into too much depth. “It is possible to spend a lot of time perfecting a way to get a data source and clean it up, then realize the data isn't helpful to the model you are creating.” The image below shows the NBA PIE dataset. The data also has a count of 486 or 486 rows. Getting the data from ESPN is a similar process to above. Other data sources to consider are salary and endorsements. ESPN has the salary information, and Forbes has a small subset of the endorsement data. Both of these data sources are in the GitHub project. Figure 5. NBA PIE dataset In Table 1, there is a listing of the data sources by name and location. In short order, we have many items from many different data sources. Table 1. NBA data sources There is still a lot of work to do to get all of the data downloaded and transformed into a unified data set. To make things even worse, collecting the data thus far was easy. There is still a big journey ahead. In looking at the shape of the data, a good place to start is to take the top eight players' endorsements and see if there is a pattern to tease out. Before that though, explore the valuation of teams in the NBA. From there, you can determine what impact a player has on the total value of an NBA franchise. Exploring team valuation for the NBA The first order of business is to create a new Jupyter Notebook. Luckily for you, the Jupyter Notebook is already created. You'll find it in the GitHub repo: exploring_team_valuation_nba. Next, import a common set of libraries that are typically used to explore data in a Jupyter Notebook. Listing 3. Common Jupyter Notebook initial imports import pandas as pd import statsmodels.api as sm import statsmodels.formula.api as smf import matplotlib.pyplot as plt import seaborn as sns color = sns.color_palette() %matplotlib inline Now you need to create a pandas data frame for each source. Listing 4. Create data frame for sources attendance_df = pd.read_csv("../data/nba_2017_attendance.csv") endorsement_df = pd.read_csv("../data/nba_2017_endorsements.csv") valuations_df = pd.read_csv("../data/nba_2017_team_valuations") elo_df = pd.read_csv("../data/nba_2017_elo.csv") A neat trick when you're working with a lot of data sources is to show the first few lines of each data frame. You can see what this looks like in the images below. Figure 6. Endorsement data frames section A Figure 7. Endorsement data frames section B Now, merge the team valuation data with attendance data and create a plot. Listing 5 provides the code for merging the pandas data frames. Listing 5. Merging pandas data frames attendance_valuation_df = attendance_df.merge(valuations_df, how="inner", on="TEAM") attendance_valuation_df.head() The image below shows the output of the merge. Figure 8. Attendance valuation data frame merge head To get a better feel for the data you just merged, do a couple of quick visualizations. The first step is to tell the notebook to display wider graphs, then to do a Seaborne pairplot, as shown below. Listing 6. Seaborn pairplot from IPython.core.display import display, HTML display(HTML("<style>.container { width:100% !important; }</style>")) sns.pairplot(attendance_valuation_df, hue="TEAM") Looking at the plots, notice the relationship between average attendance and player valuation. There is a strong linear relationship between the two features, as represented by the almost straight line formed by the points. Figure 9. Seaborn pairplot NBA attendance versus valuation Another way to look at this data is a correlation plot. To create a correlation plot, use the code provided below and the following image shows the output. Listing 7. Seaborn correlation plot corr = attendance_valuation_df.corr() sns.heatmap(corr, xticklabels=corr.columns.values, yticklabels=corr.columns.values) Figure 10. Seaborn correlation plot NBA attendance versus valuation The correlation plot shows a relationship to value in millions of dollars (of an NBA team), percentage of average capacity of the stadium that is filled (PCT), and average attendance. A heatmap showing average attendance numbers versus valuation for every team in the NBA will help you dive into this a bit more. To generate a heatmap in Seaborn, it is necessary to reshape the data into a pivot table (much like what is available in Excel). A pivot table allows the Seaborn charting to pivot, among three values and shows how each of the three columns relates to the other two. The code below shows how to reshape the data into a pivot shape. Listing 8. Seaborn heatmap plot valuations = attendance_valuation_df.pivot("TEAM", "AVG", "VALUE_MILLIONS") plt.subplots(figsize=(20,15)) ax = plt.axes() ax.set_title("NBA Team AVG Attendance vs Valuation in Millions: 2016-2017 Season") sns.heatmap(valuations,linewidths=.5, annot=True, fmt='g') Figure 11 shows some interesting outliers, for example, the Brooklyn Nets are valued at $1.8 billion, yet they have one of the lowest average attendance rates in the NBA. This is worth a look. Figure 11. Seaborn correlation plot NBA attendance versus valuation One way to investigate further is to perform a linear regression using the Statsmodels package. According to Statsmodels.org, the Statsmodels package "is a Python module that provides classes and functions for the estimation of many different statistical models, as well as for conducting statistical tests, and statistical data exploration. An extensive list of result statistics are available for each estimator." You can install the Statsmodels package by using pip install Statsmodel. Following are the three lines necessary to run the regression. Listing 9. Linear regression VALUE ~ AVG results = smf.ols('VALUE_MILLIONS ~AVG', data=attendance_valuation_df).fit() print(results.summary()) The image below shows the output of the regression. The R-squared shows that approximately 28 percent of the valuation can be explained by attendance, and the P value of 0.044 falls within the range of being statistically significant. One potential issue with the data is the plot of the residual values doesn't look completely random. This is a good start of trying to develop a model to explain what creates the valuation of an NBA franchise. Figure 12. Regression with residual plot One way to potentially add more to the model is to add in the ELO numbers of each team. According to Wikipedia, "The ELO rating system is a method for calculating the relative skill levels of players in competitor-versus-competitor games such as chess." The ELO rating system is also used in sports. ELO numbers have more information than a win/loss record because they rank according to the strength of the opponent played against. It seems like a good idea to investigate whether how good a team is affects the valuation. To do that, merge the ELO data into this data as shown below. Listing 10. Plotting ELO attendance_valuation_elo_df = attendance_df.merge(elo_df, how="inner", on="TEAM") attendance_valuation_elo_df.head() attendance_valuation_elo_df.to_csv("../data/nba_2017_att_val_elo.csv") corr_elo = attendance_valuation_elo_df.corr() plt.subplots(figsize=(20,15)) ax = plt.axes() ax.set_title("NBA Team Correlation Heatmap: 2016-2017 Season (ELO, AVG Attendance, VALUATION IN MILLIONS)") sns.heatmap(corr_elo, xticklabels=corr_elo.columns.values, yticklabels=corr_elo.columns.values) corr_elo ax = sns.lmplot(x="ELO", y="AVG", data=attendance_valuation_elo_df, hue="CONF", size=12) ax.set(xlabel='ELO Score', ylabel='Average Attendance Per Game', title="NBA Team AVG Attendance vs ELO Ranking: 2016-2017 Season") attendance_valuation_elo_df.groupby("CONF")["ELO"].median() attendance_valuation_elo_df.groupby("CONF")["AVG"].median() After the merge, there are two charts to create. The first, shown in Figure 13, is a new correlation heatmap. There are some positive correlations to examine more closely. In particular, attendance and ELO seem worth plotting out. In the heatmap below, the lighter the color, the more highly correlated two columns are. If the matrix shows the same value compared against itself, then the correlation is 1, and the square is beige. In the case of TOTAL and ELO, there appears to be a 0.5 correlation. Figure 13. ELO correlation heatmap Figure 14 plots ELO versus attendance. There does appear to be a weak linear relationship between how good a team is (ELO RANK) versus the attendance. The plot below colors the east and west scatter plots separately, along with a confidence interval. The weak linear relationship is represented by the straight line going through the points in the X,Y space. Figure 14. ELO versus attendance A linear regression will help further examine this relationship shown in the plot. Listing 11. Linear regression AVG ~ ELO results = smf.ols('AVG ~ELO', data=attendance_valuation_elo_df).fit() print(results.summary()) The output of the regression (see Figure 15) shows an R-squared of 8 percent and a P-value of 0.027, so there is a statistically significant signal here as well, but it is very weak. Figure 15. ELO versus attendance regression Unsupervised machine learning: K-means cluster One final item to tackle is to use k-means clustering to create three clusters based on AVG, ELO, and VALUE_MILLIONS. Listing 12. K-means cluster from sklearn.cluster import KMeans from sklearn.preprocessing import MinMaxScaler #Only cluster on these values numerical_df = val_housing_win_df.loc[:,["TOTAL_ATTENDANCE_MILLIONS", "ELO", "VALUE_MILLIONS", "MEDIAN_HOME_PRICE_COUNTY_MILLONS"]] #Scale to between 0 and 1 from sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler() print(scaler.fit(numerical_df)) print(scaler.transform(numerical_df)) #Add back to DataFrame from sklearn.cluster import KMeans k_means = KMeans(n_clusters=3) kmeans = k_means.fit(scaler.transform(numerical_df)) val_housing_win_df['cluster'] = kmeans.labels_ val_housing_win_df.head() You can see by the plot shown below that there are three distinct groups, and the centers of the clusters represent different labels. A note to pay attention to is that sklearn MinMaxScaler is used to scale all of the columns to a value between 0 and 1, to normalize the difference between scales. Figure 16. Team clusters The image below shows the membership of cluster 1. The main takeaways from this cluster are that they are both the best teams in the NBA and teams that have the highest average attendance. Where things break apart is on total valuation. For example, the Utah Jazz is a very good team according to the ELO, and they have very good attendance, but they are not valued as high as other members of the cluster. This may mean there is an opportunity for the Utah Jazz to make small changes that significantly raise the valuation of the team. Figure 15. Cluster membership Conclusion In Part 1 of this two-part series, you learned the basics of data science and machine learning, and started to explore the relationship of valuation, attendance, and winning NBA teams. The tutorial's code was kept in a Jupyter Notebook you can reference here. Part 2 leaves the teams and explores individual athletes in the NBA. Endorsement data, true on-the-court performance, and social power with Twitter and Wikipedia is explored. The lessons learned so far from the data exploration are: - Valuation of an NBA team is affected by average attendance. - ELO ranking (strength of team's record) is related to attendance. Generally speaking, the better a team is, the more fans attend games. - The Eastern Conference has lower median attendance and ELO ratings. Downloadable resources Related topics - Streaming analytics basics for Python developers - Data Science and Cognitive Computing courses - Data Science Fundamentals learning path - Solve problems quickly with Journeys for analytics
https://www.ibm.com/developerworks/analytics/library/ba-social-influence-python-pandas-machine-learning-r-1/
CC-MAIN-2018-30
refinedweb
3,311
56.45
Django provides built-in authentication which is good for most of the cases, but you may have needs that are being served by the existing system. For Ex: You want 'email' for authentication purpose rather than Django's username field and you want an extra field called 'display_name' as a full name for the logged in User. To meet the above requirements, we need to customize Django's built-in user model or substitute a completely customized model. In this blog post, we'll learn how to customize Django's built-in User model. Its good idea to extend Django User Model rather than writing whole new user model and there are a lot of ways but one good way is to extend it from Django itself. We get all features and properties of Django User and our own custom features on top of it. Add the following to your app that holds custom user model. In models.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): name = models.CharField(max_length=100, blank=True, null=True) and specify your custom user model in settings.py AUTH_USER_MODEL = ‘your_app.User' If you want to use your custom user model in models.py, you can get that model with `settings.AUTH_USER_MODEL` or `get_user_model()` of Django's auth module. from django.conf import settings from django.contrib.auth import get_user_model class Book(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL) (OR) from django.contrib.auth import get_user_model User = get_user_model() class Book(models.Model): author = models.ForeignKey(User) By overriding the Django's Abstract user model we can specify our own username field by overriding 'USERNAME_FIELD', By default Django User model uses 'username' field for authentication purpose, we can set 'email' as username field. Just keep the following line in your User model to make user authenticate with email rather than Django's default username field. class User(AbstractUser): name = models.CharField(max_length=100, blank=True, null=True) USERNAME_FIELD = 'email'
https://micropyramid.com/blog/how-to-create-custom-user-model-in-django/
CC-MAIN-2017-09
refinedweb
331
51.44
Is there a way to restart a program from the biggining. What I want is something like: printf ("data is wrong do you want to re-enter it or do onther student.\n"); I like to give the person a chose to reenter it or just start over the program. I know there a way to end just wander if they have one for this. If not I have to do some breack loop back in the int main() and I do not really want to do that. Thanks 3 replies to this topic #1 Posted 23 March 2009 - 01:30 PM #2 Posted 23 March 2009 - 03:42 PM I'm tempted to say use a goto statement. But thats not very popular or favored amongst programmers. It would be nice to see your code. Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused: #3 Posted 23 March 2009 - 05:01 PM fread said: Rather then goto i would use some loop statement with continue & break, ie: I'm tempted to say use a goto statement. for ( ;; ) { int result; result = 0; result = getInput(); if ( 0 == result ) { // fail; continue; } // if break; } // for #4 Posted 24 March 2009 - 10:59 AM Ok I not going to put the real program in here because its too long. So I just wroght this one that should have the idea. There maybe mitakes I have not run in though compiler or debuged it. Ya this is much more simple code but the idea is there. Hope you guys understand it better now. Edited by cook777, 24 March 2009 - 11:00 AM. #include <stdio.h> #include <ctype.h> void getClass (int class); void getHours (int hours); int main () { int class[1]; int hours[1]; int x=1; char option; do{ getClass (class); getHours (hours); printf ("Do you want to do anther student? Y for yes and N for No n"); scanf ("%c",option); toupper(option) if (option == 'N') x=0; }while (x==1); return 0; } void getClass (int class) { printf ("Enter in the class number"); scanf ("%d",class[0]); printf ("\n"); } getHours (int hours) { case 1234 : hours[0] = 3; case 2134 : hours[0] = 1; case 1243 : hours[0] = 3; case 1324 : hours[0] = 4; default : // This is were I like it to start the program over. } Ya this is much more simple code but the idea is there. Hope you guys understand it better now. Edited by cook777, 24 March 2009 - 11:00 AM. fix code
http://forum.codecall.net/topic/46317-c-restarting-a-program/
crawl-003
refinedweb
417
87.25
Opened 11 years ago Closed 10 years ago #1149 closed defect (duplicate) 'now' outputs in UTC and UTC-offset wrong on Windows Description When the 'now' tag is used in a template, the output is always in UTC and the 'TIME_ZONE' setting appears to be used incorrectly. This behavior has been observed on Windows XP Pro (I have not tried it on other platforms). Example #1: settings.py: TIME_ZONE = 'America/Chicago' template: {% now "O Y-M-d H:i" %} Windows Control Panel -> Date/Time -> Time Zone: US Central Result: +0000 2005-Dec-31 16:40 This result is exactly 6 hours ahead of the current local time. Example #2 (same as above but with the following change: settings.py: TIME_ZONE = '' Result: +1800 2005-Dec-31 10:41 This result is the correct local time but the UTC offset of +1800 is wrong. Change History (7) comment:1 Changed 11 years ago by comment:2 Changed 11 years ago by It seems that both the now tag and date filter are broken in templates, which is odd because django.utils.dateformat.format doesn't return bogus information (aside from it being '+1600' rather than '-800', and the expansion of 'PST'): >>> from django.utils.dateformat import format >>> from django.models.news import entries >>> pub_date = entries.get_list()[0].pub_date >>> pub_date datetime.datetime(2006, 1, 7, 21, 53) >>> format(pub_date, "h:i A T (O)") '09:53 PM Pacific Standard Time (+1600)' But {{ entry.pub_date|date:"h:i A T (O)" }} Outputs '09:53 PM Ame (+0000)'. I assume that 'Ame' comes from "America/Los_Angeles", my TIME_ZONE. comment:3 Changed 11 years ago by Changing 'America/Los_Angeles' to 'PST8PDT' fixes this ('O' outputs +1600, 'T' outputs 'PST'), but only after the development server was killed and started again--for some reason the autoreload after saving settings.py doesn't update TIME_ZONE. (Probably the cause of the strange behavior of format, above, as I was changing the TIME_ZONE settings but not manually restarting the server.) comment:4 Changed 11 years ago by comment:5 Changed 10 years ago by Putting TIME_ZONE = in settings.py does not work for Windows 2000 because when trying to run the server, I get next error: .python manage.py runserver Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "C:\python25\lib\site-packages\django\core\management.py", line 1404, in execute_manager execute_from_command_line(action_mapping, argv) File "C:\python25\lib\site-packages\django\core\management.py", line 1307, in execute_from_command_line from django.utils import translation File "C:\python25\lib\site-packages\django\utils\translation\init.py", lin e 3, in <module> if settings.USE_I18N: File "C:\python25\lib\site-packages\django\conf\init.py", line 27, in ge tattr self._import_settings() File "C:\python25\lib\site-packages\django\conf\init.py", line 54, in _imp ort_settings self._target = Settings(settings_module) File "C:\python25\lib\site-packages\django\conf\init.py", line 109, in i nit os.environTZ? = self.TIME_ZONE File "C:\python25/lib\os.py", line 426, in setitem putenv(key, item) OSError: [Errno 2] No such file or directory comment:6 Changed 10 years ago by Sorry: Putting TIME_ZONE = "" in settings.py does not work for Windows 2000 because when trying ...... Seems to me like a dublicate of ticket #1119, isn't it?
https://code.djangoproject.com/ticket/1149
CC-MAIN-2017-04
refinedweb
549
50.43
Given vector a = [a1, a2, a3] and vector b = [b1, b2, b3], the dot product of the vectors, Simply put, the dot product is the sum of the products of the corresponding entries in two vectors. In Python, you can use the numpy.dot() function to quickly calculate the dot product between two vectors: import numpy as np np.dot(a, b) The following examples show how to use this function in practice. Example 1: Calculate Dot Product Between Two Vectors The following code shows how to use numpy.dot() to calculate the dot product between two vectors: import numpy as np #define vectors a = [7, 2, 2] b = [1, 4, 9] #calculate dot product between vectors np.dot(a, b) 33 Here is how this value was calculated: - a · b = 7*1 + 2*4 + 2*9 - a · b = 7 + 8 + 18 - a · b = 33 Example 2: Calculate Dot Product Between Two Columns The following code shows how to use numpy.dot() to calculate the dot product between two columns in a pandas DataFrame: import pandas as pd import numpy as np #create DataFrame df = pd.DataFrame({'A': [4, 6, 7, 7, 9], 'B': [5, 7, 7, 2, 2], 'C': [11, 8, 9, 6, 1]}) #view DataFrame df A B C 0 4 5 11 1 6 7 8 2 7 7 9 3 7 2 6 4 9 2 1 #calculate dot product between column A and column C np.dot(df.A, df.C) 206 Here is how this value was calculated: - A · C = 4*11 + 6*8 + 7*9 + 7*6 + 9*1 - A · C = 44 + 48 + 63 + 42 + 9 - A · C = 206 Note: Keep in mind that Python will throw an error if the two vectors you’re calculating the dot product for have different lengths. Additional Resources How to Add Rows to a Pandas DataFrame How to Add a Numpy Array to a Pandas DataFrame How to Calculate Rolling Correlation in Pandas
https://www.statology.org/numpy-dot-product/
CC-MAIN-2021-39
refinedweb
327
60.28
“Making a phone call with a .NET application was THAT simple? And I always thought [that] only a real savvy can do such a state-of-the-art work.” were the comments given by a friend of mine when I showed him this demo project. But the truth is; that this task was never so easy until a real savant made it easy as pie for all of us. Thanks to Julmar Technology ( ). These folks have done a magnificent work and provided us with a class library built upon TAPI 2.x (distributed with Windows XP). TAPI, so far does not give any interface which can be used in .NET to make a phone call. Nonetheless, with the class library we have in our hand now, making a phone call is as easy as instantiating an object and calling its appropriate functions. So let’s see the magic. Creation of Phone Caller Application: The main logic behind this application is; we want to display a simple Listbox with a few persons’ information populated in it. Each person will have an ID, Name, Phone Number etc. When user selects a person in the list it will show person’s information in the textboxes present on the form. Phone Number textbox has a button in front of it. Clicking this button will initiate a phone call. Let’s quickly take a look at how this form is going to look like: So we’ll create a simple windows application and add references to our DLL file which gives our application the ability to make phone calls. · Start Microsoft Visual Studio 2003 or later. · Click Create New Project · In New Project dialog box, select Visual C# in Project types panel on left. · Select Windows Forms Application in the Templates panel on right. Give a decent physical path and name to your project and select OK. By doing this, IDE will create a windows application project with a default form added into it. · Rename your Form1.cs to frmPersons.cs · Next step we need Atapi.dll; the heart of this application · Atapi.dll can be found here · Unzip this file and reach bin folder and get the dll. · Add a reference to Atapi.dll by right clicking project root node in Solution Explorer · Add app.config After completing the above steps your Solution Explorer should look something like this: We also want to keep a complete log of TapiManager’s activities; app.config keeps the path of the log file. <appSettings> <add key=“LogFilePath“ value=“D:\My Work\prjMakePhoneCall\PhoneCall.log“/> </appSettings> Now let’s move to cs code of frmPersons.cs; namespaces first here: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Configuration; using JulMar.Atapi; And then comes the rest of the code: I’ve created a small class of Person. This class contains some private data members and their corresponding public properties, followed by 2 overloaded constructors. That’s how the class looks like, and I’ve written the class within frmPersons.cs itself: [Serializable] public class Person { private int id; private string name; private string phone; private string city; private string state; private string zip; private string country; public int ID { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } public string Phone { get { return phone; } set { phone = value; } } public string City { get { return city; } set { city = value; } } public string State { get { return state; } set { state = value; } } public string Zip { get { return zip; } set { zip = value; } } public string Country { get { return country; } set { country = value; } } public Person() { } public Person(int id, string name, string phone, string city, string state, string zip, string country) { this.id = id; this.name = name; this.phone = phone; this.city = city; this.state = state; this.zip = zip; this.country = country; } } Now what I’m going to do is: · Create a generic list of Person class. · Hard code some Person’s IDs, Names, phone numbers etc; and fill that list. · Store that list in a class level variable. · Set lstPerson.DataSource to list of persons. · Create a button in front of phone number text box and write code behind click event of that button. · Write code behind selected index changed event of the listbox. Let’s start doing this step-by-step, that’s how our frmPersons.cs file starts: namespace prjMakePhoneCall { // Line numbers are given for understanding and are not part of the actual code public partial class frmPersons : Form { 01 private TapiManager tapiManager = new TapiManager(“prjMakePhoneCall”); 02 private List<Person> lstPerson = new List<Person>(); 03 private string lineName, logEntry = string.Empty; 04 public frmPersons() { InitializeComponent(); } At line 01, TapiManager type variable is declared at class level. At line 02, I’m creating a class level variable which will contain all the persons information used for this application. Line 03 has two string variables lineName will keep the name of the telephone line tapi manager will use to make phone calls. logEntry will keep all the log of the phone calls made or attempted to make during an application session. Line 04 is standard form constructor. Now let’s see form load event: // Line numbers are given for understanding and are not part of the actual code private void frmPersons_Load(object sender, EventArgs e) { 01 tapiManager.Initialize(); 02 this.GetPersonList(); 03 this.ShowData(); 04 this.lineName = (tapiManager != null && tapiManager.Lines.Length > 0 ? tapiManager.Lines[0].Name : string.Empty); } Line 01 initializes form level tapiManager. In line 02 I’m calling GetPersonList() method which will create a list of persons. Person information is hard coded in this method and then saved in class level lstPersons variable. The same list of person will be displayed in our lstNames listbox in the method ShowData(), line 03. In real world application, GetPersonList() method will get list of persons from database instead of getting hard coded persons. Line 04 sets the name of the telephone line. When we call tapiManager’s initialize method it gets a list of all the lines attached to the computer, but we are interested in only the one connected with modem, which in most cases is present at 0th index. Now let’s see our GetPersonList(): /// <summary> /// Instead of hard coding Persons’ names you can get persons /// from Database /// </summary> /// <returns></returns> private List<Person> GetPersonList() { lstPerson.Add(new Person(1, “Roger”, “9,1-262-527-0200”, “New York”, “New York”, “24234”, “USA”)); lstPerson.Add(new Person(2, “Kishor”, “6-692-1234”, “Banglore”, “Mahrashtra”, “4426”, “India”)); lstPerson.Add(new Person(3, “Allmand”, “262-532-3415”, “Milwaukee”, “Wisconsin”, “52342”, “USA”)); lstPerson.Add(new Person(4, “Chris”, “262-532-3416”, string.Empty, “California”, string.Empty, “USA”)); lstPerson.Add(new Person(5, “Ahmed”, “051-2856021”, “Islamabad”, “Federal Capital”, “44000”, “Pakistan” )); return lstPerson; } Quite simple and straight forward, no explanation needed for this method. Let’s quickly jump to ShowData() method. private void ShowData() { this.lstNames.DisplayMember = “Name”; this.lstNames.ValueMember = “ID”; this.lstNames.DataSource = lstPerson; } This method is even simpler than the previous one. Now let’s take a look at lstNames’s selected index change event: private void lstNames_SelectedIndexChanged(object sender, EventArgs e) { this.txtID.Text = this.lstPerson[this.lstNames.SelectedIndex].ID.ToString(); this.txtName.Text = this.lstPerson[this.lstNames.SelectedIndex].Name; this.txtPhone.Text = this.lstPerson[this.lstNames.SelectedIndex].Phone; this.txtCity.Text = this.lstPerson[this.lstNames.SelectedIndex].City; this.txtState.Text = this.lstPerson[this.lstNames.SelectedIndex].State; this.txtZip.Text = this.lstPerson[this.lstNames.SelectedIndex].Zip; this.txtCountry.Text = this.lstPerson[this.lstNames.SelectedIndex].Country; } For simplicity, I’ve used the selected index property of the listbox to refer the person in the generic list of persons, a class level variable. In real world application this logic won’t be that simple. Before I jump to the method which actually makes phone calls for us let me explain a few very important methods that are responsible for some functionality like log entry and closing the application and shutting down the tapiManager. So let’s take a look at them one by one. private void frmPersons_FormClosed(object sender, FormClosedEventArgs e) { tapiManager.Shutdown(); Application.ExitThread(); } When form is closed I want to shut down tapiManager and since this is the only form in my application, I want to exit the application thread as well. private void frmPersons_FormClosing(object sender, FormClosingEventArgs e) { StreamWriter logWriter = new StreamWriter(ConfigurationSettings.AppSettings[“LogFilePath”], true); try { string[] logEntries = this.logEntry.Split(‘|’); for (int i = 0; i < logEntries.Length; i++) logWriter.WriteLine(logEntries[i]); } catch (Exception exc) { } finally { logWriter.Flush(); logWriter.Close(); } } When form is closing I want all the activity done during the form was open to be saved in a log file. For this purpose I keep on saving user’s each and every activity in a class level string variable separated by “|” sign (explained below) and in this event I open a log file with stream writer, split the string on the basis of “|” and insert activities line by line. After all these methods this is the time for showing and explaining what magic the phone button does which actually makes a phone call. private void btnCall_Click(object sender, EventArgs e) { if(this.txtPhone.Text.Trim().Length > 0) this.MakePhoneCall(this.txtPhone.Text); } When Call button is clicked, it simply checks the phone number text box’s text length. If it is more than 0 then it passes it to MakePhoneCall method. private void MakePhoneCall(string phoneNumber) { 01 TapiLine line = tapiManager.GetLineByName(this.lineName, true); 02 if (line != null) { 03 if (!line.IsOpen) 04 line.Open(MediaModes.DataModem); 05 line.NewCall += new EventHandler<NewCallEventArgs>(line_NewCall); 06 line.CallInfoChanged += new EventHandler<CallInfoChangeEventArgs>(line_CallInfoChanged); 07 line.CallStateChanged += new EventHandler<CallStateEventArgs>(line_CallStateChanged); 08 if (phoneNumber.Length > 0) { 09 MakeCallParams makeCallParams = new MakeCallParams(); 10 makeCallParams.DialPause = 2000; try { 11 TapiCall call = line.MakeCall(phoneNumber, null, makeCallParams); 12 this.MakeLogEntry(“Created call “ + phoneNumber + ” -> “ + call, “Sending…”); } catch (Exception exc) { 13 if (exc.Message.IndexOf(“[0x80000005]”) > -1 && tapiManager != null) { 14 tapiManager.Shutdown(); 15 tapiManager = new TapiManager(“prjMakePhoneCall”); 16 if (tapiManager.Initialize()) 17 this.MakePhoneCall(phoneNumber); } } } } } After MakePhoneCall method there is nothing of vital importance in this code. So let’s just quickly see what event handlers of line object are doing. private void line_NewCall(object sender, NewCallEventArgs e) { this.MakeLogEntry(“New call: “ + e.Call, e.Privilege.ToString()); } private void line_CallStateChanged(object sender, CallStateEventArgs e) { this.MakeLogEntry(“CallState: “ + e.Call.ToString(), e.CallState.ToString()); } private void line_CallInfoChanged(object sender, CallInfoChangeEventArgs e) { this.MakeLogEntry(“CallInfo: “ + e.Call.ToString(), e.Change.ToString()); } All of these methods are just making log entries. Now let’s take a look at MakeLogEntry method which is even simpler than the above ones: private void MakeLogEntry(string callInfo, string status) { this.logEntry += DateTime.Now.ToShortDateString() + ” “ + DateTime.Now.ToLongTimeString() + ” : “ + callInfo + “, “ + status + “|”; } This method prefixes date and time stamp with every log entry sent by any method. After running a couple of test calls, call log on my machine looks like this: Before I end this article, for novice programmers, I want to show how you have to connect telephone chords with phone and computer. For this purpose you need 3 chords, one connected to landline port on the wall like this: Secondly, this chord should be connected to a connector with two other wires as shown below: One of these two chords would go into the computer’s modem like this: And finally the last chord needs to go in the telephone set: That’s it, simple and clean. After creating this demo application, you have become a savvy programmer who can develop .NET applications having ability to make phone calls. Don’t forget to give me your feedback on this article and also feel free to contact me if you have any questions. Hasta La Vista folks… It is simply superb. I really thankful to you for posting this article. Comment by Viswanath — October 18, 2008 @ 4:40 am still any technique, please send through mail Comment by Viswanath — October 18, 2008 @ 4:41 am Thank you Viswanath. Another very useful article is on its way, keep checking. When it’s published, I shall send you its link on e-mail as well. Comment by Mukarram Mukhtar — October 21, 2008 @ 3:19 pm Super its too much helpfull to me , but can i send sms through this tapi plz reply if u have any link forword me. Comment by shrikant — December 9, 2008 @ 4:58 am hello… Jyotsna — December 13, 2008 @ 10:24 am @ Shrikant: At this point I’m not sure if this code can be used for SMS; I think you’ll have to explore further and put some effort. Please let us know as well, if you find out something good. @ Jyotsna: Are you sure you connected all the wires correctly as I explained above? We were able to make phone calls with this configuration in United States over land lines and cell phones both. Did you try lifting call sender’s phone receiver and talk? We noticed that some modems were half-duplex and did not transfer voice in both directions. Keep on posting and let us have your feedback… Comment by Mukarram Mukhtar — December 17, 2008 @ 5:58 am I have a general question, I made my application by getting help from Ur article and its doing great, I wanted to play back a wav file, but when I request for playback terminal its unable to connect and I dunt know whats the reason can it be due to my modem ?? please can You reply me in detail about playback terminal, Thanks 🙂 Comment by Ali — December 17, 2008 @ 4:15 pm hi, thanks for such app. but i have problem. when i make a call and callstate become: connected, how can i notify the called person picked up the receiver(phone) or just dropped it? i mean i wanna to determine is my partner answered to my call, or not. the call state events just say connect, when dialling finished, and disconnect when the call is over, no reporting what happened between to states. i really appreciate you if help me. Comment by techind — December 18, 2008 @ 8:21 am @ Ali & techind: At this point I’m not sure if this code can be used for the purpose you are trying to achieve; I think you’ll have to explore further and put some effort. Please let us know as well, if you find out something good. Comment by Mukarram Mukhtar — December 23, 2008 @ 2:28 am Hello, Can u send me the source code. My id is shanaj_ml2000@yahoo.com Thanks Comment by Shan — August 11, 2009 @ 10:05 am This article is very fruitful for me. Comment by Rakhi — December 24, 2009 @ 9:42 am Enjoy the tasty juicy fruit of it 🙂 Comment by Mukarram Mukhtar — December 24, 2009 @ 5:00 pm Great post, I think I am missing something though, I can create a call great, however I cant disconnect the call, what command do I use to disconnect and go back to idle? Comment by Aaron — April 23, 2010 @ 9:17 pm Aaron, I don’t think you need to call any method to end the call, just simply click on the hang up button. Comment by Mukarram Mukhtar — April 26, 2010 @ 1:00 pm This is really very helpful. Thank you very 2 much. 🙂 Comment by Girish Audichya — September 1, 2010 @ 12:55 pm Really a nice and helpful post. I have created a c# windows form application and did all the things you have done. I But I got the following error: “Could not load file or assembly ‘Atapi, Version=1.1.3.30, Culture=neutral, PublicKeyToken=6148c7b92dc86471’ or one of its dependencies. An attempt was made to load a program with an incorrect format.” And it is not running the application at all. I’m using Windows 7 and 64 bit machine. Please help me. Comment by Sunny — September 20, 2010 @ 7:48 pm How can I make it work in a 64bit machine? Comment by Sunny — September 20, 2010 @ 7:55 pm Did you get Atapi dll from their website? Link of their website is given in the article above. See if they have made a dll for 64-bit machines available. If they have, then you have a chance, otherwise, you can request them to update their class libraries. Good Luck! Comment by Mukarram Mukhtar — September 20, 2010 @ 9:02 pm Once I changed the platform from Visual Studio it is running. But, the problem is it is not running from the other side, I wanted to make a phone call and play a voice message to that number. Do you have any reference to this work? I would really appreciate if you could help me doing it. Thanks, -Sunny. Comment by Sunny — September 23, 2010 @ 9:37 pm u done well…. Comment by minahill — December 28, 2010 @ 11:13 am minahill — January 15, 2011 @ 2:10 pm You have to pick up your phone’s receiver and then speak. This software is not designed to use your PC’s mic and speakers to exchange voice data over the phone line. Albeit I’m planning to write such a component. Comment by Mukarram Mukhtar — January 18, 2011 @ 2:38 pm hi such a nyce application i need help from that how can i get the caller number i hav tried this but unable to get that please help i will be very helpful to U . Regards SAAD Comment by Saadullah — June 18, 2011 @ 3:56 pm Saad, can you please rephrase your question? I couldn’t get it, you want to get “caller number”? In this case YOU are the caller. So why and where do you want to get your own number? Comment by Mukarram Mukhtar — June 20, 2011 @ 1:57 pm for example you are the caller and calling on my number then defiantly on my phone set there will be ur number but i wanted to show that number on my PC from here U are making the call but i want to see the caller number who is calling on my number Thaks for the reply Comment by CAllER ID problem — June 21, 2011 @ 9:44 am Ok, this particular project is for sending outgoing calls from pc to phone line only, and not for receiving incoming calls . Not that it’s not possible to achieve but in this project you won’t find it. So please go ahead and put some effort to get it done. Comment by Mukarram Mukhtar — June 21, 2011 @ 2:16 pm I have done every thing but i m unable to do that i think if U can help me in that so i will be very thankfull to U Comment by Saadullah — June 22, 2011 @ 7:43 pm after a long search i got this info..thanks in advance..after building the application will surely post my results…thanks a lot.. Comment by soumya sanjeev — July 9, 2011 @ 11:22 am You’re most welcome Soumya, as they say, real gems are always difficult to find 😉 Comment by Mukarram Mukhtar — July 11, 2011 @ 4:01 pm Great post, thanks a lot for it. Does anybody know any (web)service that provides such functionality. Unfortunately I cannot plug my server into a phone socket… Comment by lust auf shoppen — July 13, 2011 @ 1:48 pm hi sir is headphones are necessary to make a phone call from computer through .net application? what is required and any configuration have to do in computer? plz help me sir. Comment by rajesh — October 26, 2011 @ 8:57 am Rajesh, you don’t need headphones attached with the computer, however you do need headset attached with the phone through which you can talk and hear other person’s voice. There are no configurations other than what is mentioned in the article above. So, try it and I hope it will be all good. Let me know if you need the project source code. Good luck! Comment by Mukarram Mukhtar — October 26, 2011 @ 2:23 pm hi, iam getting error in this line line.open(mediamodes.datamodem) ========================== errormessage: lineopen failed[0X8000002F]invalid media mode ===================== is it necessary to connect one line to landline phone Comment by rajesh — December 19, 2011 @ 6:05 am hi sir, i will explain whats going on myside, Iam using airtel broadband connection,they provide one chord with two lines.one line is for internet and another connected to landline phone. which line have to connect pc and land line plz help me. regards rajesh Comment by rajesh — December 19, 2011 @ 6:16 am i have the same error did you solve it? Comment by asmaa — June 19, 2012 @ 3:01 pm nice article Comment by uma — November 8, 2011 @ 6:44 am Hi, very useful article but I’m experiencing a very annoying problem; I keep getting this error: “Could not load file or assembly ‘Atapi, Version=1.2.0.0, Culture=neutral, PublicKeyToken=6148c7b92dc86471’ or one of its dependencies. The system cannot find the file specified.” Do you know why I might be getting this – any help would be greatly appreciated! Thanks. Comment by Tony Hales — December 9, 2011 @ 10:49 am Hello, Is there any way to get the incoming number like callerid . Comment by Shanaj — December 17, 2011 @ 6:18 am hi sir iam getting this error on line.open(mediamodes.datamodem) ====================================== error meessage: line.open failed[0x80000052F]invalid media mode ====================================== what have to do Comment by rajesh — December 19, 2011 @ 10:11 am Rajesh, please connect all the wires as explained in the article above. If you have a different setup of land line connectivity then perhaps this article won’t work for you. Good luck! Comment by Mukarram Mukhtar — December 19, 2011 @ 5:25 pm Hi! great..I have no other words. The application is very good plus you explained it in very detail. Awesome work… Comment by Niki Rawal — December 19, 2011 @ 1:20 pm hi sir, iam connected all the wires as explained in the article above.but it is not working please confirm “RAS PPP0E Line0000” is this line name correct or not. please help me. Comment by rajesh — December 22, 2011 @ 3:59 am Hi Sir, This is a good article . Comment by Madhu Sudan Mahanta — March 22, 2012 @ 2:00 pm Thank you very much for your nice comment, Madhu! 🙂 Comment by Mukarram Mukhtar — March 23, 2012 @ 2:55 pm hi, i errormessage: lineopen failed[0X8000002F]invalid media mode ===================== is it necessary to connect one line to landline phone i have airtel connection i have three cable one come from main connection there is connection in between what u have told in above one for modem one for phone which line is used for laptop and which is used for phone please tell me onne the connector line for modem and line to connect phone . plz plz reply me one your site or on my email id : afsar_sm2002@yahoo.com The article is awesome u done a greate job . afsarhussain s m Comment by Afsarhussain S M — April 10, 2012 @ 7:50 am TapiLine line = tapimanager.GetLineByName(this.lineName, true); I am gettint null for lineName. So the app is not moving forward. Can you please explain me why am i gettting null for lineName? What mistake have i made and any solution for that? Comment by Anup Vaze — May 17, 2012 @ 11:37 am Hi Anup, Let me forward you the source code of the project. Perhaps, that way you’ll get better idea of what’s going on. Otherwise, it’s really very difficult for me to troubleshoot your code remotely. Comment by Mukarram Mukhtar — May 17, 2012 @ 2:19 pm please i have problem when i click the call button and give me this error lineopen failed[0X8000002F]invalid media mode. i don’t know why Comment by asmaa — June 21, 2012 @ 7:37 am TapiLine line = tapimanager.GetLineByName(this.lineName,true); if(line!=null) { if (!line.IsOpen) // line.Open(MediaModes.DataModem); line.Open(MediaModes.DigitalData); line.NewCall += new EventHandler(line_NewCall); line.CallInfoChanged +=new EventHandler(line_CallInfoChanged); line.CallStateChanged += new EventHandler(line_CallStateChanged); //———-when i put DigitalData instead of DataModem it is no errors but it does not work but when i put DataModem give me error lineopen failed[0X8000002F]invalid media mode …… Comment by asmaa — June 23, 2012 @ 11:25 am How to get current my line name? And make call? Thanks! Comment by Cristian — October 22, 2012 @ 9:44 am I am regular visitor, how are you everybody? This piece of writing posted at this site is really pleasant. Comment by cold calling scripts — December 18, 2012 @ 11:36 pm You should take part in a contest for one of the finest sites online. I am going to recommend this site! Comment by kvik lån — January 11, 2013 @ 1:22 pm Thanks, appreciate your feedback! 🙂 Comment by Mukarram Mukhtar — January 14, 2013 @ 9:21 pm hi sir for laptop it is working.for desktop it is not working.where do i have to connect that landline phone port to computer Comment by rajesh — February 23, 2013 @ 10:13 am This is the right site for everyone who hopes to understand this topic. You know so much its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject that has been discussed for decades. Great stuff, just excellent! Comment by Read the Full Post — March 2, 2013 @ 8:53 pm how do I play a .wav file or .mp3 file once the receiver has picked up the call Comment by Marlon Gowdie — March 24, 2013 @ 12:58 am Hi! I could have sworn I’ve visited this blog before but after going through some of the articles I realized it’s new to me. Regardless, I’m definitely happy I stumbled upon it and I’ll be book-marking it and checking back often! Comment by Branden — April 25, 2013 @ 6:11 am Hello, Thank you for the sample code. I have some Exception when calling MakephoneCall. This is the exception message:lineMakeCall failed [0x80000019] Invalid LINECALLPARAMS structure Have you some idea for this error? Comment by rabe — May 21, 2013 @ 2:53 pm Really when someone doesn’t be aware of after that its up to other users that they will assist, so here it takes place. Comment by Cory — June 21, 2013 @ 8:08 pm
https://mukarrammukhtar.wordpress.com/creation-of-phone-caller-application/
CC-MAIN-2019-30
refinedweb
4,428
64.81
haven't sorted out the packaging for distribution yet because I've been "busy" doing other things. Your question has prompted me to get on with it. If I can get it sorted out before you get another alternative, I'll post again to let you know where to download it. (Eventually, it will be freely downloadable from my web site - when I get that updated too ;-)) I may use it, unless yours is done soon or I can figure out how to make the Netbeans IDE do a search. It will search Jar files but it seems one must mount them directly which is pretty tedious and creates a multistep process when it should be one step. On another note, do you know if likewise there is a utility to show just which classes an application utilizes, and extract them to a temporary directory so that they can be repackaged into one compact .jar? Or will just do it without the temporary directory. FYI and for reference here is an application that used to do something similar: Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more. I wish! ;-) I could have done with that for this packaging problem :-) OK. I've got the package together. You can download it (temporarily) from: I would really appreciate it if you could provide some feedback on it. To any other experts who may be considering downloading this application - I would appreciate it if you could hold-off for now. The tool is still not ready to be released into the wild. However if you insist on looking at it, I would consider it a professional courtesy if you would also provide feedback. Experts Exchange Solution brought to you by Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.Start your 7-day free trial Per feedback, here are some minor suggestions(I'll e-mail you directly if I have more): 1) Per removing sources, it would be nice if one could use the delete key or be able to right click and get a context menu with a delete option. 2) Maybe add the capability to be able to put in multiple search strings at one time. 3) Maybe add a button to clear the results window. 4) When you distribute the Jars you might just mention the location of the file that contains the main method. you may need to change DIR_NAME field. -------------------------- import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.Enumeration; import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.StringTokenizer; public class TestJar { public static void main(String[] args) { if(args.length != 1) { System.out.println("USAGE: } else { JarFile jf = null; Matcher m = null; String token = ""; StringTokenizer st = null; StringBuffer sb = null; final String DIR_NAME = "\\\\bng-tv4850\\bea\\webl File dirName = new File (DIR_NAME); String[] fileList = dirName.list(); Pattern p = Pattern.compile("[a-zA-Z]* try { //System.out.println("Dire outer:for (int i=0; i < fileList.length;i++) { sb = new StringBuffer(); //System.out.println(fileL if(Pattern.matches("[a-zA- { jf = new JarFile(DIR_NAME+"\\"+file inner:for (Enumeration e = jf.entries(); e.hasMoreElements() ;) { sb.append(e.nextElement()) } st = new StringTokenizer(sb.toStrin while (st.hasMoreTokens()) { token = st.nextToken("/"); m = p.matcher(token.trim()); if( m != null && m.matches()) { System.out.println(args[0] break outer; } } } } } catch(IOException e) { e.printStackTrace(); } } } } may be useful to u for class dependency find. I havent tried it out myself..:-( Thanx Taurus Thanx for the suggestions :-) I'm glad (relieved ;-)) it worked. I would appreciate it if you could let me know: 1) What OS have you run it on (I've only given it a good hammering on Linux)? 2) Do you think that the way it was packaged was acceptable? I packaged it into a jar and included a readme file for running it from the command line. If it worked with no problems from within Netbeans, that's even better news ;-) I've put in two of the changes you suggested - delete key and clear button. I'll post on this question again when I've published it properly on my web site. Thanx again. Jim. Whether or not you do this your app. is a life saver.
https://www.experts-exchange.com/questions/20823472/How-to-find-packages-class-files.html
CC-MAIN-2018-30
refinedweb
737
66.94
sup guys i was wondering if anyone could help a newbie , i'v just finished building a large map for my survival game and just finished with some animations on AI / Player model. only the player model have that problem it goes trough everything , i'v did a little bit of testing and changed to a mouse rotation , and stil i rotate it down in ground charachter (player model) keeps going down . it walks like there is no psyhics :( Here is the controller code wish someone could help me out to fix it :( using System.Collections; using UnityEngine; public class Zombiecontroll : MonoBehaviour { static Animator anim; public float speed = 10.0F; public float rotationSpeed = 100.0F; //Mouse Look public float horizontalSpeed = 2.0F; public float verticalSpeed = 2.0F; //End of moouse look // Use this for initialization void Start () { anim = GetComponent<Animator>(); } // Update is called once per frame void Update() { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; transform.Translate(0, 0, translation); transform.Rotate(0, rotation, 0); if (Input.GetButtonDown("Jump")) { anim.SetTrigger("anim_Jump"); } if (translation != 0) { anim.SetBool("anim_Running", true); anim.SetBool("anim_idlee", false); } else { anim.SetBool("anim_Running", false); anim.SetBool("anim_idlee", true); /* { /* } //mouse look start codes float h = horizontalSpeed * Input.GetAxis("Mouse X"); float v = verticalSpeed * Input.GetAxis("Mouse Y"); transform.Rotate(v, h, 0); //mouse look end coding */ } } } Sorry for my bad english, i just started like 4 months ago with unity and had a nice idea to create a survial game :( i'm lost of hope already, been 24h awake to try sovle , not even google helped me Answer by ValakhP · Nov 19, 2017 at 09:16 PM Check if you have collider and the rigidbody on it. Also check if all obstacles have colliders. You can learn more about it here: thank you , but anyways i rescripted the whole charachter controller the one i posted was a mess at all , now i finally optimized the player movament , and fixed the bugs aka ; stop in middle of air while jump from high buildings and more :) fast tip to anyone reading this post make yourself a nice conroller and give him commands what to do :) aka; took me about 4 scripts to make it work perfect but i'm proud of my work ValakhP thanks for helping me out , the collidier and rigidbody are outated on transform codes :) its better to force the player movament and apply animations trough Animator :) just sorted it out after looking many yt tutorials by holistic3d this woman is the power of Unity do I use the GetComponent to access the RigidBody? 2 Answers [Daydream][C#]How would I make a simple directional controller with Google Daydream Controller? 1 Answer Coroutine endlessly looping? 0 Answers How to control a plant or vine? 0 Answers Remember position for a simple player controller (Left/Right)? 0 Answers
https://answers.unity.com/questions/1433415/charachter-goes-trough-everything-even-the-terrain.html
CC-MAIN-2019-43
refinedweb
482
54.93
Welcome to the Jboss 3.0 Tutorial Welcome to the Jboss 3.0 Tutorial  ... about our JBoss Tutorial, or anything else that comes to mind. Post your...; Building Web Application With Ant and Deploying on Jboss 3.0 JBoss - error during deploy - Java Beginners JBoss - error during deploy Hello! I've followed your fantastic tutorial about JBoss but I got stucked in exercise 2. I use JBoss AS 5 (don't... understanding this issue? Thank you so much! Hi Friend, Please visit JBoss Tutorials: Learn JBoss Step by Step is present. ADS4ThUnitADS At roseindia.net you will find large number of JBoss... of the learners to make JBoss learning easy. Jboss 3.0 Tutorial 10 Minutes... Session Bean Jboss 3.2 Tutorial about jboss - Java Beginners about jboss can you please explain about jboss...how to deploy,where the temp and lock is there...total information about jboss to use in java message services(JMS Building Web Application With Ant and Deploying on Jboss 3.0 will show you how to build you web application and install on the Jboss 3.0...;!-- ==================================================== --> <project name="Jboss 3.0 tutorial... Building Web Application With Ant and Deploying on Jboss 3.0 jboss and struts - Struts Deploy JBoss and Struts how to deploy struts 2 applications in jboss 4... the WAR file to the /server/default/deploy folder. Hello,You...;JBoss_home>/server/default/deploy folder.Jboss will automatically deploy Thank U - Java Beginners Thank U Thank U very Much Sir,Its Very Very Useful for Me. From SUSHANT Dynamic Proxies - Short Tutorial is all we do, so we call ourselves "Java Specialists". Thank you...Dynamic Proxies - Short Tutorial 2001-01-18 The Java Specialists' Newsletter [Issue 005] - Dynamic Proxies - Short Tutorial Author: Dr. Christoph G developing a Session Bean and a Servlet and deploy the web application on JBoss 3.0 Welcome to the Jboss 3.0 Tutorial  ... the web application on JBoss 3.0 Server. This example shows you how to write...;!-- ==================================================== --> <project name="Jboss 3.0 tutorial developing a Session Bean and a Servlet and deploy the web application on JBoss 3.0 ;!-- ==================================================== --> <project name="Jboss 3.0 tutorial series"... I will show you how to develop a Stateless Session Bean and a Servlet and deploy the web application on JBoss 3.0 Server. Our application is thin Struts Tutorial: Struts 2 Tutorial for Web application development, Jakarta Struts Tutorial Struts 1 migrate your project to Struts 2. You can still find Struts 1 tutorial... Struts 2 Tutorials - Jakarta Struts Tutorial Learn Struts 2... the video tutorials of Struts 2 Framework. You will learn the basics and advanced display Helloworld through servlets using jboss display Helloworld through servlets using jboss I'm beginner,Can You please Write the code for this.Including WEB.INF Please visit the following link: Jboss 3.2 EJB Examples Jboss 3.2 EJB Examples  ... be required by different customers Part 1 Stateless session bean jboss 3.2... the Open-source & free Jboss. Jboss3.2 is favoured by many medium-level This JDK Tutorial shows you how to wrap text inside cells of a JTable Cole and Sami. Thank you very much! Most of the solutions...JDK Tutorial - Multi-line cells in JTable in JDK 1.4+ This JDK Tutorial shows... If you are reading this, and have not subscribed, please consider doing wml tutorial our WAP tutorial you will learn about WAP and WML, and how to convert your HTML... on top of the SMS technology. This SMS tutorial will provide you useful... sites using wml, this tutorial is for you. WAP jboss sever jboss sever Hi how to configure data source in jboss server and connection pooling Thanks Kalins naik JBoss Tutorials jsp-jboss jsp-jboss where to keep jsp in jboss Can you provide me Hibernate configuration tutorial? Can you provide me Hibernate configuration tutorial? Hello There, I want to learn about Hibernate configuration, Can anyone provide me with hibernate configuration tutorial> Thanks Building Web Application With Ant and Deploying on Jboss 3.0 Hibernate 4 Annotations Tutorial features. This video tutorial explains you the steps and the code for creating.... In this video tutorial you have learned how to create Hibernate 4 Annotation example program. Video tutorial explained you the steps needed to create Hibernate example how to install jboss drools how to install jboss drools how to install jboss drools Logging Tutorial - Part 1 Logging Tutorial - Part 1 2000-12-14 The Java Specialists' Newsletter [Issue 003] - Logging part 1 Author: Dr. Heinz M. Kabutz If you are reading... subscribe page. You can subscribe either via email or RSS. Hooking into the shutdown call - tutorial environment. Thank you again for your support and the feedback you send me. I... If you are reading this, and have not subscribed, please consider doing it now by going to our subscribe page. You can subscribe either via email or RSS how to install jboss - EJB how to install jboss when i installed jboss at startup jboss generating errors . unable to run ejb3 AWT-swings tutorial - Swing AWT .. i want some tutorials and some examples related to swings.. thank you sir..waiting for your answer. Hi friend, I am sending you a link. This link will help you. Please visit for more information. http Hibernate Tutorial Hibernate Tutorial This section contains the various aspects of Hibernate... (ORM) framework for Java. Hibernate is provided by the JBoss organization... to download hibernate ? To download the latest version of hibernate you can POI Tutorial POI Tutorial Hi, How to access the Excel file in Java? I have heard about POI in Java. Can anyone share me the url of the tutorial? Thanks Hi, Yes you can use the POI api for reading and writing Excel file. Check HTML Tutorial you HTML from scratch. This HTML tutorial is for beginners. After learning this tutorial your will be able to create your own web sites. If you want to become a web programmer even then this tutorial will be useful for you Struts - Jboss - I-Report - Struts Struts - Jboss - I-Report Hi i am a beginner in Java programming and in my application i wanted to generate a report (based on database) using Struts, Jboss , I Report ARRAY TUTORIAL ARRAY TUTORIAL PLEASE HELP ME ANSWER THESE ARRAY TUTORIAL Q1... or False? If false, explain why. Q2 - In Java, you must declare an array before you can use it. In declaring the array, you must provide two important pieces Dojo Tutorial Dojo Tutorial In this tutorial, you will learn everything about the dojo. After completing the tutorial you will be able to develop good applications using Dojo frameworkQuery Tutorial jQuery Tutorial jQuery is a cross browser, java Script library created by 'John Resig' in 2006 with a nice motto: "Write less, do more". It handles the client side scripting of HTML. jQuery simplifies  JSF Tutorial JSF Tutorial I am novice to JSF Programming. And want to learn the Java Server Faces (JSF) technology online. So, could you please list down few helpful JSF Tutorials. Also, which is the latest version of Java Server Faces (JSF Java Tutorial Learn Java with the Java Tutorial and articles. Welcome to the Java Tutorial section of our famous Java Tutorial website. This Java Tutorial programming section is for the beginners. This section teaches you the basics of Java Regularexpressions Tutorial Regular Expressions Introduction In this tutorial I will show you how to use Regular Expressions in Java. What is Regular Expressions? A regular expression is a pattern of text in regular language. It describes what to match XML Tutorial Language. In our XML tutorial you will learn what XML is and the difference between... school Tutorial: At W3Schools you will find all the Web-building... Tutorial: the Java XML Tutorial, is an online manual that can quickly get you which is better server for java applications? apache or jboss? which is better server for java applications? apache or jboss? which is better server? apache or jboss Struts Tutorials Tutorial This complete reference of Jakarta Struts shows you how to develop Struts applications using ant and deploy on the JBoss Application Server. Ant script... ActionForms. In this tutorial, you will learn to perform this validation declaratively Struts Links - Links to Many Struts Resources you how to develop Struts applications using ant and deploy on the JBoss... this example to show you additional features of Struts. Jakarta Struts 1.2 Tutorial..., JBoss, Tomcat. Most of these tutorials appear to be free, but some you apparently JBoss Application Server JBoss Application Server JBoss is an open source Java EE-based application server. JBoss is cross-platform, usable on any operating system that supports Java JSTL Tutorial Part 2 In this tutorial you will learn about some advance JSTL example of JSP Spring Annotation Tutorial Spring Annotation Tutorial In Spring Framework you can use annotations... as Controller you can simply write @Controller before the class declaration @Controller public class AnnotationController { You can use RequestMapping JBoss AS Training JBoss AS Training Description of JBoss Application Server JBoss is a free, open source application... enterprise-class security, and resource management. Nowdays, the Jboss Java Tutorial learning all the above tutorial you will be able to develop any kind of enterprise... Java Tutorials If you are a beginner and looking for the Java tutorials... libraries that helps the programmer to develop any kind of applications. You Args tutorial Args tutorial Are you looking for Args tutorial in Java Technolog? Args represents the command line arguments in the Java program. You can pass any number... to use the Java Args. Java Args Tutorial. Thanks Tutorial | JDK 6 Tutorial | Java UDP Tutorial | Java Threading Tutorial | Java 5 Tutorials | EJB Tutorial | Jboss 3.0 Tutorial | JPA Tutorial... | Site Map | Business Software Services India Java Tutorial Section Quartz Tutorial Quartz Tutorial In this Quartz Tutorial you will how to use Quartz Job scheduler in your java.... For example you can use Quartz Job scheduler to send emails to your registered Counting bytes on Sockets,java tutorial,java tutorials 058] - Counting bytes on Sockets Author: Dr. Heinz M. Kabutz If you... to our subscribe page. You can subscribe either via email or RSS. Welcome... and help offered after last week's newsletter. All I can say is "thanks". Thank using Swing | Chess Application In Java Swing Jboss 3.0 Tutorial Section 10... Map | Business Software Services India JPA Tutorial Section JDBC vs...-to-One Relationship | JPA-QL Queries Java Swing Tutorial Section Java Tutorial with examples Java Tutorial with examples What is the good urls of java tutorial with examples on your website? Thanks Hi, We have many java tutorial with examples codes. You can view all these at Java Example Codes java.io Tutorial in Java. The purpose of this tutorial is to provide you an overview how...java.io Tutorial Nearly all the applications gives output depend on some input.... To perform any type of input and output(I/O) in Java, you need java.io package PHP Basics Tutorial Index PHP Basic Tutorial: Learn the Basics of PHP scripting through our PHP Basic Tutorial series. The PHP Basic Tutorial is design for new programmers who want to learn the PHP program ASAP. These tutorials will help you grasping the PHP Display helloworld using servlet in jboss the following link: About the Tutorial Topics About the Tutorial Topics (This is genaral question) Why ASP.Net or VB.net is not there in the Tutorial Topics? Are you not interested in those topics? This is my suggestion: ->You can add Genaral questions/Suggestion as one DHTML Tutorial generation browsers would support. This tutorial will teach you about how.... In the tutorial, you will be briefed about the simple DHTML that can be made...DHTML Tutorial DHTML, which stands for Dynamic HTML , is a very popular mode Struts 2 Video Tutorial Video Tutorial. What is the url of Struts 2 Video Tutorial on roseindia.net website? Is there any source code of the tutorial also? Thanks Hi, Yes your are right. You can learn Struts 2 very easily with the Struts 2 Video Ant Tutorial Ant Tutorial In this section we will learn about the various aspect of Apache Ant such as what is Apache Ant, what is build tool, how to configure ant... and the various of examples you may go through the following link http Photoshop Cloud Shape Tutorial org.htmlparser.util.ParserException: C:\downloadingarticles\websitereader\In this tutorial, i'll show you how to make shapes formed by clouds (The system cannot find the file specified SQL tutorial with examples SQL tutorial with examples Hi, I am looking for good SQL tutorial with examples code. Please give me good urls for SQL tutorial with example code..., Codes and Tutorials page. Above tutorial is for beginners and helps a Simple EJB Application Tutorial | Complete Spring Tutorial | Building Web Application With Ant and Deploying on Jboss 3.0 | J2EE Tutorial - Java Bean... Map | Business Software Services India J2EE Tutorial Section Application JSTL Tutorial JSTL Tutorial In this section we will read about JSTL. You will read about how... you would have to first download the JSTL JARs. Then it should be kept inside... the parameter etc. To use the JSTL Core Tags you would have to use the following JMagick Tutorial these activity from the Java code also. In this tutorial I will teach you how you can use...); } } In this tutorial you have learned how to download, install and create simple...JMagick Tutorial - Download, install and create simple program JMagick library Tutorial For Java beginners Tutorial For Java beginners I am beginners in Java. Is there any good tutorial and example for beginners in Java? I want to learn Java before Jan 2014. Thanks Yes, If you spend time you can learn Java in the month Hibernate 4 annotations tutorial Hibernate 4 annotations tutorial. I think there is good tutorial on your site. Please tell me the url of Hibernate 4 annotations tutorial. Thanks hi.../hibernate/hibernate4/hibernateAnnotation.shtml may this will be helpful for you. Hi DOJO, DOJO 1.0.2 tutorial, DOJO Tutorial application. Dojo Button Example In this tutorial, you will learn... as alert. Adding image on button In this tutorial, you...Dojo 1.0.2 Tutorial   Attachement in Web Service + EJB 3 + Jboss Attachement in Web Service + EJB 3 + Jboss How to send attachements in Web Service using EJB3 with JBoss Application Server Photoshop Tutorial :background image ; This example is about a bullet background, normally you use background with color and any image. But with this tutorial, you can learn and design your... on new (CTRL + N key) then adjust file size as you design. Fill Color: Go Objective C Tutorial ; In this Objective C Tutorial we will provide you step-by-step information in detail. You will find this object c tutorial very useful. You can quickly... Tutorial This tutorial will help you learn the core concepts of objective c Depth-first Polymorphism - tutorial 009] - Depth-first Polymorphism Author: Dr. Heinz M. Kabutz If you... to our subscribe page. You can subscribe either via email or RSS. Welcome... at "in-the-veld" tips and tricks used by Java professionals. I want to thank all PHP Tutorial The Roseindia Technologies has offered this tutorial for the beginners who want... guide will inform you all the basic knowledge essential for being a beginner’s programmer. Our beginners PHP tutorial is full of examples that will help Quartz Tutorial Struts 2 online tutorial Struts 2 online tutorial Where to learn struts 2 online tutorial? Is there any good tutorials on roseindia.net for learning struts 2 online tutorial... gives you the links of latest Struts tutorials. Thanks DOJO Tutorial Dojo Tutorial In this tutorial, you will learn about the dojo and its directory structure. The main purpose of this tutorial, when a new user Best PHP tutorial for beginners Tutorial index page. You find good tutorials for learning php from beginning. Installing PHP Installing PHP LAMP PHP MySQL Tutorial index page. Above tutorials...Best PHP tutorial for beginners Hi Friends, I want to learn PHP Change the text of a button whenever you clicked tutorial we'll study that how to change the label of a button on clicking on itself. You can make a separate actionScript file, but in this tutorial that has been... Change the text of a button whenever you clicked JBoss Seam - Web 2.0 Applications JBoss Seam - Web 2.0 Applications JBoss Seam is a powerful new application framework developed by JBoss, a division of Red Hat for building next JBoss Application Server JBoss Application Server Introduction to JBoss Application Server JBoss... management. Features of JBoss Application Server JBoss
http://www.roseindia.net/tutorialhelp/comment/94373
CC-MAIN-2014-10
refinedweb
2,780
58.48
Welcome to WebmasterWorld Guest from 54.221.49.52 Forum Moderators: LifeinAsia & httpwebwitch What is the difference between all of these? Which is appropriate for a webmaster? I understand that the specifics vary from state to state, but in a nutshell what does each choice offer me, legally as well as financially? Do I need to declare that I am one of these immediately, or is there a certian amount of money I have to make before I am required to do so? It's not like I have employees... it's just me, running this "business" from out of my own place. When does my basement hobby turn into a business with reportable income? Also, I have not registered my company name in any way yet. Is this a must? Or can I wait until I'm earning enough money that I need to declare my income? A lot to ask, I know, but I'm not making enough to hire a lawyer or an accountant yet... you guys are all I've got. Thanks for any helpful advice anyone throw my way. Having said that, you will need to register your business. This is simply a legal registration saying MrMee also is using the name "xyz" to trade under. Under this simple sole-trader structure, all income gets lumped together with any other income/salary (like having 2 jobs -- except you can claim on business expenses). To incorporate as a company (limited or unlimited) means you wish to create a separate legal entity (called the xyz company) which will be be treated separately from you re incomes/taxes etc. This can have benefits like spliting income, being able to raise finance easier and, if you are a proprietary LIMITED company, limiting your liability if anything goes wrong. The draw back to creating a separate legal entity is you have to bring other people in (directors) to steer the company and take responsiblity for anything that goes wrong. This means following legal rules, having meetings and producing paperwork to prove all is OK. The idea of incorporating (coming together to create a "body") is designed for a group of people to be able to co-create and operate a single venture. The exact form of incorporation will depend on what type of legal entity you wish to create: business, non-profit, professional organisation etc. and the benefits/risks you are willing to take. This doesn't sound where you are at the moment so you would most likely need to simply register your business under a sole trader structure. Good Luck *the above is provided as a guide only and doesn't constitute professional legal advise. Any resemblance to persons living or dead is entirely coincidental and the author advises that, if the pain persists, you should see your doctor. (that should cover any legal issues :)) Most of us probably started as you have. Depending upon how large and legal you want to become will determine exactly what steps you need to take. It has nothing (well, almost) to do with how much you are making. For starters, as a one person business (sole proprietor), if you wanted to use a business name instead of your personal name ("XYZ Website Design" instead of Joe Smith), in most cases you would go to your local county courthouse clerks office and fill out a "dba" (doing business as) form, pay them a small fee, and you are set. They will also check to make sure the name you want isn't already in use locally. Also, as a business (even a sole proprietor) declaring your income "can" have tax benefits. Most new businesses have costs which actually can offset income and possibly provide a tax advantage depending upon your individual situation (your mileage may vary). It (sole proprietorship) simply invloves filling out and including Schedule C with your income tax return (in the US, anyway). It's not very complicated, really. Just keep good records and follow the instructions (and rules). HTH. [Disclaimer - I am not a lawyer. The above is provided as a guide only and does not constitute professional legal advise. If you need professional advice, consult an attorney and/or accountant. Keep out of reach of children. Chew before swallowing. Contents may be HOT. Put your right foot in, put your right foot out... Etc., etc.] Which is appropriate for a webmaster? There is absolutely not a reliable and accurate answer to that. No matter what business you're in, webmaster or not, which type of business entity to form, if any, depends on your individual financial and tax situation, liability concerns and long-term goals. There is no way to be sure you're making the right choice other than either doing plenty of research and evaluation or accepting the advice of a qualified expert who himself has a good understanding of your situation. About some of the choices: a sole proprietorship, as has been said, will mean you'll report the income and expenses incurred in the operation of your business on a Schedule C, carry the profit to your 1040 (you won't be able to use a 1040C or 1040EZ) and be taxed there. There is no new legal entity; the business is you and you are the business. Incorporation (there is no difference between, as you put it, "incorporation" and "corporation) creates a separate legal entity that will have its own legal and tax responsibilities. Of course, as a shareholder and officer of that corporation you will still have personal responsibilities and liabilities. In it's basic form, a "C" corporation, that corporation will file its own tax returns. Any money you pay yourself as salary, consulting fees, dividends, or any other distribution will have to be accounted for on your own return. Most likely your corporation could elect to be classified as an "S" corporation, which would mean that the income and tax liability pass through to you. The corporation has to file a form, but has no tax liability. An LLC is a construct of the individual states, and isn't recognized as a business entity type by the IRS. By default it would be treated as a partnership, which again would mean the tax liability passes to you (and any other "members" of the LLC). But an LLC can elect to be treated as any other kind of entity by making a filing; so some LLC's members choose to be taxed in the same way as a "C" corporation. Again, which is best for you is impossible to say without knowing more... each has its advantages and disadvantages. But it can probably be said that the LLC form has become very popular for small businesses owned by one or two people. In the interim, though, there's not likely to be any harm in remaining a sole proprietorship, re-evaluating when the business is stable and after you've had time to give the options careful consideration. [Oh, and we're all doing disclaimers? OK: I am not a lawyer, but I played one in the senior play.] While organizing your business as a corporation or limited liability company is often discussed in light of tax benefits, there is another major advantage to doing business as a corporation or LLC--liability protection. The liability protection a corporation or LLC will provide you depend on the state or country in which it is organized. In Nevada, where we are located, Directors, Officers and Shareholders of corporations are provided with very good liability protection, and can't be held liable for corporate debts unless they committed some sort of fraud (the preceding is not a legal opinion). Also, the number of Directors and Officers needed will vary from state to state and country to country. Some states require a minimum of three Directors and three Officers, and others require only one person who can fill all offices. The one point I want to get across: it is very dangerous in our society to do business as a sole proprietor (even more dangerous as a general partnership). Sole Proprietors have ZERO liability protection, which means if someone sues your sole proprietorship, you could lose everything you own to pay off the judgement. In our sue-happy world, it just makes sense to limit your liability by incorporating. Tax-wise, it also makes sense if your CPA can guide you into making wise business decisions regarding salaries, dividends, S-corporation status, etc. I'm not an attorney or CPA... the above is not meant to be legal or professional advice. If you feel you need legal or professional advice, the advice or an attorney or qualified professional should be sought.
https://www.webmasterworld.com/forum31/666.htm
CC-MAIN-2015-32
refinedweb
1,457
61.26
I'm making a car retal program for a friends new business, heres the deal: He has 5 locations, 5 different type of cars in each, different pricing on all, and different price depending if rented during weekend. So the program will look like: Which location 1-5: Which type of car: Which weekday: How many KM driven: Then the out the following: Rental Charge: 15.00 Extra Kms Charge: 70.00 Total Charge: 85.00 - Deposit 500.00 Refund: $415.00 --- So far I'm here, Getting all the information now I don't know where to go from here, case statements, if statements, switch?Getting all the information now I don't know where to go from here, case statements, if statements, switch?Code: #include <stdio.h> main() { int location, veh_type, weekday, km, insurance, prev; printf("Enter Location:"); scanf("%d", &location); printf("Enter Vehicle Type:"); scanf("%d", &veh_type); printf("Enter Weekday:"); scanf("%d", &weekday); printf("Enter Amount of KM Driven:"); scanf("%d", &km); printf("Enter insurance (1-Yes/0-No):"); scanf("%d", &insurance); printf("Have you previously rented with US? (1-Yes/0-No):"); scanf("%d", &prev); }
https://cboard.cprogramming.com/c-programming/149266-car-rental-program-printable-thread.html
CC-MAIN-2017-26
refinedweb
189
65.32
Introduction: Raspberry Pi - MPL3115A2 Precision Altimeter Sensor Python Tutorial The MPL3115A2 employs a MEMS pressure sensor with an I2C interface to provide accurate Pressure/Altitude and Temperature data. The sensor outputs are digitized by a high resolution 24-bit ADC. Internal processing removes compensation tasks from the host MCU system. It is capable of detecting a change in only 0.05 kPa which equates to a 0.3m change in altitude.PL3115A2 sensor and the other end to the I2C shield. Also connect the Ethernet cable to the pi or you can use a WiFi module. Connections are shown in the picture above. Step 3: Code: The python code for MPL3115A2 can be downloaded from our Github repository- DCUBE Store Community. Here is the link. # MPL3115A2 # This code is designed to work with the MPL3115A2_I2CS I2C Mini Module import smbus import time # Get I2C bus bus = smbus.SMBus(1) # MPL3115A2 address, 0x60(96) # Select control register, 0x26(38) # 0xB9(185) Active mode, OSR = 128, Altimeter mode bus.write_byte_data(0x60, 0x26, 0xB9) # MPL3115A2 address, 0x60(96) # Select data configuration register, 0x13(19) # 0x07(07) Data ready event enabled for altitude, pressure, temperature bus.write_byte_data(0x60, 0x13, 0x07) # MPL3115A2 address, 0x60(96) # Select control register, 0x26(38) # 0xB9(185) Active mode, OSR = 128, Altimeter mode bus.write_byte_data(0x60, 0x26, 0xB9) time.sleep(1) # MPL3115A2 address, 0x60(96) # Read data back from 0x00(00), 6 bytes # status, tHeight MSB1, tHeight MSB, tHeight LSB, temp MSB, temp LSB data = bus.read_i2c_block_data(0x60, 0x00, 6) # Convert the data to 20-bits tHeight = ((data[1] * 65536) + (data[2] * 256) + (data[3] & 0xF0)) / 16 temp = ((data[4] * 256) + (data[5] & 0xF0)) / 16 altitude = tHeight / 16.0 cTemp = temp / 16.0 fTemp = cTemp * 1.8 + 32 # MPL3115A2 address, 0x60(96) # Select control register, 0x26(38) # 0x39(57) Active mode, OSR = 128, Barometer mode bus.write_byte_data(0x60, 0x26, 0x39) time.sleep(1) # MPL3115A2 address, 0x60(96) # Read data back from 0x00(00), 4 bytes # status, pres MSB1, pres MSB, pres LSB data = bus.read_i2c_block_data(0x60, 0x00, 4) # Convert the data to 20-bits pres = ((data[1] * 65536) + (data[2] * 256) + (data[3] & 0xF0)) / 16 pressure = (pres / 4.0) / 1000.0 # Output data to screen print "Pressure : %.2f kPa" %pressure print "Altitude : %.2f m" %altitude print "Temperature in Celsius : %.2f C" %cTemp print "Temperature in Fahrenheit : %.2f F" %fTemp Step 4: Applications: Various applications of MPL3115A2 includes High Accuracy Altimetry, Smartphones/Tablets, Personal Electronics Altimetry etc. It can also be incorporated in GPS Dead Reckoning, GPS Enhancement for Emergency Services, Map Assist, Navigation as well as Weather Station Equipment. Be the First to Share Recommendations 2 Comments 1 year ago Will this work with the adafruit mpl3115a2 model Question 3 years ago on Step 4 Does the sensor give the correct height from ground?? I need to know as I will be using this sensor in my college project.please enlighten me.
https://www.instructables.com/Raspberry-Pi-MPL3115A2-Precision-Altimeter-Sensor--1/
CC-MAIN-2022-33
refinedweb
482
66.84
Problem Statement: Write a Python program to find least common multiple or LCM of two numbers. Description: LCM of two numbers is the smallest number which can be completely divided by both the numbers. Example: Input: 20 25 Output: LCM of 20 and 25 is 100. Explanation: 20*5=100 and 25*4=100 and 100 is lowest number which can be divided by both numbers. Input: 5 7 Output: LCM of 5 and 7 is 35. Explanation: 5*7=35 and 7*5=35 and 35 is lowest number which can be divided by both numbers. Python Program: Find LCM of two Numbers def find_lcm(num1, num2): smallerNum = min(num1, num2) greaterNum = max(num1, num2) for i in range(1, greaterNum+1): if((smallerNum*i)%greaterNum==0): return smallerNum*i return num1*num2 num1 = 4 num2 = 22 #num1,num2 = map(int, input("Enter two numbers separated by space:\n").split(" ")) print("LCM of {0} and {1} is {2}".format(num1, num2, find_lcm(num1, num2))) LCM of 4 and 22 is 44 Before diving into the logic of the code you should know that worst-case LCM of two numbers (a, b) is a*b. The first step is to find the smaller and larger number among the two. We iterate from 1 to the greater number (inclusive). We choose the greater number because the worst-case LCM is smaller number*greater number. Then we multiply each number to the smaller number and check if it is divisible by the greater number. Once we find the number which is divisible by both numbers then it is the LCM. Python Program: Find LCM using GCD This program is based on the fact that the product of two numbers is equal to the LCM and HCF of those numbers. Number1*Number2 = LCM(Number1, Number2)*HCF(Number1, Number2) LCM(Number1, Number2) = (Number1*Number2)/ HCF(Number1, Number2) Here is the Python implementation of the above formula to find LCM of two numbers using GCD or HCF. def find_hcf(num1, num2): smallerNum = min(num1, num2) gcd = 1 for i in range(1, smallerNum+1): if(num1%i==0 and num2%i==0): gcd = i return gcd num1 = 4 num2 = 22 #num1,num2 = map(int, input("Enter two numbers separated by space:\n").split(" ")) lcm = (num1*num2)/find_hcf(num1, num2) print("LCM of {0} and {1} is {2}".format(num1, num2, lcm)) LCM of 4 and 22 is 44.0 You can read more about the logic to find HCF or GCD in Python. The LCM is calculated using the formula described above and we print the results.
https://holycoders.com/python-program-to-find-lcm/
CC-MAIN-2020-34
refinedweb
432
70.43
Emacs is, by nature, a very difficult program to use. Few people can even figure out how to exit it, let alone use it. I won't cover configuring emacs, as that is a whole art unto itself, one which I have yet to master. You probably already have emacs installed, I'll assume you do. At the command prompt, type: emacs Emacs will start up with a scratch buffer, which isn't really meant for anything other than scratch notes. So, we must bring emacs up with a filename on the command-line. Before we do that, we must exit emacs. Hit C-x C-c(hold down control, then press x, then press c), and it'll exit. Now, let's bring it up with a filename: emacs bork.txt The screen will look something like this: Buffers Files Tools Edit Search Mule Help ----:---F1 bork.txt (Text)--L1--All----------------------------------- (New file) Now, let's look at the bottom status line. It displays the filename we're working on, informs that it's using the Text mode(more on emacs modes later in this doc) , that we're on line 1, and it's display all of the file. As an example of what it will display while editing a file with information in it, here's what's on the status bar on my screen: ----:**-F1 emacs.html (HTML)--L59--70%---------------------------------- The two asterisks show that file has been changed since I last saved, I'm editing emacs.html, emacs is using it's HTML mode, I'm on line 59 and 70% of file is displayed on the screen. Now, type some text in. You'll notice the asterisks and line number. Now, let's save your masterpeice! Hit C-x C-s(that's hold down control, press x then s), and at the bottom it will say: Wrote /home/paul/bork.txt You've just saved your work! Let's exit emacs and bring it back up with our text file, and you can see for certain that the file has been saved. That covers the basics you need to get around with emacs, now on to.... Emacs has a built-in LISP interpreter, making it so that emacs can be programmed to do various tasks. This allows it to handle HTML, SGML, shell scripts, C code, texinfo source, TeX source, etc. more appropriately. The classic thing to do with programmable calculators has always been to write games for them - guess what one of the classic things to do with a programmable text editor like emacs is. Emacs has a LISP-based version of the classic pseudo-AI program, Eliza. In this case, it's designed to act as a psychoanalyst. Now this part can get a bit tricky, as the official key used to run these modes is named 'meta'. PCs don't have a true-blue meta key, so it's often mapped to one of the alt keys, or a control key. Hit M-x, trying first the left alt, then right alt and same for controls, you'll know when you've hit the right one when the bottom line displays M-x with the cursor beside it. Now, type doctor and hit enter. The following text will appear on your screen: I am the psychotherapist. Please, describe your problems. Each time you are finished talking, type RET twice. Go ahead, chatter with doc for a bit. It can be entertaining... Back so soon? Well, it does get a wee bit boring after a while... Now that you're back, we're gonna write some C code to show the benefit of using emacs. I want you bring up emacs, and edit ~/.emacs Put the following in it: (add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1))) This may, at first glance, look like gibberish. It's actually LISP code, at seeing this you now understand why some derisevly state that LISP really stands for Lots of Irritating Superfluous Parentheses. Fortunately, you don't need to know LISP right now - though you will have to learn it to do much configuring with emacs. Save the file, and start emacs editing a file named foo.c Type the following: #include <stdio.h> main(){printf("\nHello.\n");} Doesn't look like what's here, does it? Notice how emacs automagically indents the code properly and indicates to you that the braces are matched? If you don't program in C, you won't realize just how neat this is. Beleive me, if you do much coding, it's a godsend! Emacs has similar modes for HTML, SGML, even plaintext. It can read e-mail, usenet news and browse the web. Emacs includes everything, including the kitchen sink. Browse the docs, and use it, and with time you will begin to use emacs to it's full capacity. May the source be with you, --Paul Anderson, paul@geeky1.ebtech.net
http://www.tldp.org/LDP/LG/issue35/anderson.html
CC-MAIN-2014-41
refinedweb
830
82.65
Intro: 4 People Made This Project! ekayudhipratama made it! PerL16 made it! JamesM246 made it! benterou made it! 31 Discussions Question 7 months ago what if you dont have a 0538A? 10 months ago Got compiled no but giving blank backlight display mine using 0x3F address is there any shorting to be done 1 year ago it almost works, it uploads fine but i got no text on my lcd, any tips is it different with a mac book? Reply 1 year ago. Reply 1 year ago Oh man, thank you so much for this comment!!! I was slowly going nuts... mine is the 0x3F too... for two of my LCDs... I never thought about this address, as it's really mentioned in every tutorial... Again - Thanks! Reply 1 year ago I'm having the same problem... everything connected up and uploading, no compile errors, and a blank screen. :( 1 year ago. 3 years ago. Reply 1 year ago in the top bar, go to [ Sketch > Include Libraries > Manage Libraries > Filter ] and type in the library that you need to download find what you need, get the latest version and click install. then go to [ Sketch > Include Libraries > (...Library Name...) and click on it. then in the script bar it should pop up with #include <...Library Name...> Hope this helps ~Scratchndent Reply 2 years ago Where are you unzipping the library ? Reply 2 years ago Do hou have lcd.h Librarie installed? Reply 2 years ago have you tried the tutorial on how to find your serial code because that was a big problem for me!!! 1 year ago LiquidCrystal_I2C.h does not exist and neither does LCD.h also not compatible with any other lcd librarys or script. 2 years ago Great tutorial:) Thanks for sharing. 2 years ago what's the device behind the LCD that allows connection with the SDA and SLC pins on the arduino? Reply 2 years ago Hi, I believe they are called I2C interface.... Check the link, they sometimes sell them separate from the LCD. 3 years ago on Introduction it is really hard. got any tips? Reply 2 years ago Follow the video and it should work. 3 years ago on Introduction Very nice and rich blog I have tried to gather all my collection of websites and youtube channels and videos in one place. There are many things also to introduce to you in an elegant way so I established this site : and I hope you like it. Regards, ----------------------- 3 years ago Hmm looks like a normal lcd with a addon board cool i wonder if you can buy the board separte
https://www.instructables.com/id/How-to-connect-a-serial-LCD-to-an-Arduino-UNO/
CC-MAIN-2018-47
refinedweb
441
85.28
React: Virtual DOM vs actual DOM One of my first interviews with skilled when preparing for my job hunting, they asked me to explain what was my definition of the virtual DOM in React… In this post, I am going to explain what is my understanding of this mysterious virtual DOM. DOM Just to get things straight, DOM stands for Document Object Model and is an abstraction of a structured text. For web developers, this text is an HTML code, and the DOM is simply called HTML DOM. Elements of HTML become nodes in the DOM. Virtual DOM The virtual DOM is an abstraction of the HTML DOM. It is lightweight and detached from the browser-specific implementation details. Since the DOM itself was already an abstraction, the virtual DOM is, in fact, an abstraction of an abstraction. Perhaps it’s better to think of the virtual DOM as React’s local and simplified copy of the HTML DOM. There is no big difference between the virtual DOM and the “real” DOM. This is why the JSX parts of the React code can almost look like pure HTML: In most cases, when you have an HTML code and you want to make it a static React component, all you have to do is: - Return the HTML code using the render function - Replace class attribute name to className, because class is a reserved word in Javascript. ReactElement vs ReactComponent When talking about the virtual DOM, it’s important to see the difference between these two: React Elements - elements can have other type properties other than native HTML elements. We can create an object representation of a DOM node using the createElement method: const element = React.createElement( 'div', {id: 'login-btn'}, 'Login' ) When this is rendered to the DOM (using ReactDOM.render), we'll have a new DOM node that looks like this: <div id='login-btn'>Login</div> React Components - A React Component is a template. A blueprint. A global definition. This can be either a function or a class (with a render function). - If react sees a class or a function as the first argument, it will check to see what element it renders, given the corresponding props and will continue to do this until there are no more createElementinvocations which have a class or a function as their first argument. - When React sees an element with a function or class type, it will consult with that component to know which element it should return, given the corresponding props. - At the end of this processes, React will have a full object representation of the DOM tree. This whole process is called reconciliation in React and is triggered each time setStateor ReactDOM.renderis called. - Class-Based Components Create a Class Component: import React, { Component } from "react";class ClassComponent extends Component {render() {return <h1>Hello, world</h1>;}} - Formatting when exporting the component - ES7 extension provides short-cuts to create class headers in VSCode (`Rce + tab` auto-creates a class) - allow you to manipulate the life cycle within the object itself - Binding to `this` 2. Functional Components import React from "react";const FunctionalComponent = () => {return <h1>Hello, world</h1>;}; - Requires hooks to accomplish similar results as class (e.g., class has component_did_mount) - The clear difference is the syntax. Just like in their names, a functional component is just a plain JavaScript function that returns JSX. A class component is a JavaScript class that extends React.Component which has a render method. - ES7 extension provides short-cuts in VSCode (`Rfc + tab` auto-creates a class header) What makes the difference? ReactComponents are great, we would love to have plenty of them since they are easy to manage. But they have no access to the virtual DOM — and we would like to do as much as possible there. Whenever a ReactComponent is changing the state, we want to make as little changes to the “real” DOM as possible. So this is how React deals with it. The ReactComponent is converted to the ReactElement. Now the ReactElement can be inserted to the virtual DOM, compared and updated fast and easily. The point is - it’s done faster than it would be in the “regular” DOM. Summary A virtual DOM object has the same properties as a real DOM object, but it lacks the real thing’s power to directly change what’s on the screen. Manipulating the DOM is slow. Manipulating the virtual DOM is much faster, because nothing gets drawn onscreen.
https://matthieubertrand5.medium.com/react-virtual-dom-vs-actual-dom-6597bfc6d219?responsesOpen=true&source=---------5----------------------------
CC-MAIN-2021-31
refinedweb
745
60.24
08 February 2011 23:04 [Source: ICIS news] (adds updates throughout) HOUSTON (ICIS)--Enterprise Products on Tuesday said the main facilities at its Mont Belvieu natural gas liquids (NGL) complex in ?xml:namespace> As of late Tuesday afternoon, one worker was still unaccounted for, the company said. Moreover, Ethylene for February was offered at 49.00 cents/lb, up from 45.50 cents/lb in the morning, according to market sources. Meanwhile, bids for February rose to 46.50 cents/lb from 44.00 cents/lb. Ethylene traded at 44.25-46.00 cents/lb on Monday. The fire at LyondellBasell said it reduced rates at its nearby cracker in ExxonMobil said its giant “As a precaution, we have taken steps necessary to ensure our facilities remain isolated from the incident,” said ExxonMobil spokesman Kevin Allexon. Chevron Phillips, which operates an olefins facility in nearby Cedar Bayou, and a polyolefins facility in Pasadena, Texas, would offer no comments regarding any potential impact of the Mont Belvieu blast. Shell said the fire had no impact on its downstream operations or those of Motiva, but was still assessing the situation. A former The former employee said the pipelines were not built to withstand a large explosion. The former employee added that if the pipes are burning, the fire should burn out in short time. The gushing appearance of the fire could indicate a pipeline leak, the former employee said, resulting from the release of high pressure of propane, butane or ethane. However, the former employee also cautioned that the blast could be from a wellhead, which could take days or weeks to burn out. The Enterprise Products also operates an NGL fractionation plant in Mont Belvieu. Overall, the NGL fractionation plant has a total capacity of 305,000 bbl/day, the company said on its website. Market sources said NGL prices were offered higher following the fire, but few trades were likely to be completed until more information is released. Mont Belvieu is located about 30 miles (48 km) east of (Additional reporting by Sheena Martin, Al Greenwood, Brian Ford and William Lemos)
http://www.icis.com/Articles/2011/02/08/9433468/enterprise-says-most-texas-operations-unaffected-by-fire.html
CC-MAIN-2014-10
refinedweb
351
62.98
Quickstart: Using single-page navigation (HTML) Learn about the single-page navigation model and how you can implement it in your own app by using PageControl objects and WinJS.Navigation features. For help choosing the best navigation pattern for your app, see Navigation patterns. Also, you can see the Flat navigation and Hierarchical navigation patterns in action as part of our App features, start to finish series. Prerequisites We assume that you know how to create a basic app. If you need help with this, see Create your first app using JavaScript. We assume that you are familiar with the Windows Library for JavaScript controls. For help using WinJS controls, see Quickstart: Adding Windows Library for JavaScript controls and styles. Creating a basic link One of the simplest and most commonly used forms of navigation is the hyperlink. Here's HTML code that creates a hyperlink that navigates to page2.html. Because it's a relative link, the system assumes that page2.html is a local page that's part of your app, relative to current document's base URL. For example, if the link appears in /folder/default.html, clicking the link takes you to /folder/page2.html. If you want to explicitly specify the full URI for a local file in your application, use the new packaged-content URL scheme (ms-appx) like this: - ms-appx://package name/file path You can omit the package name if you want. - ms-appx:///file path Here's an example. You can use the ms-appx URL scheme to refer to any file that is included in the app’s package. However, we recommend using relative URLs because they're resolved automatically based on the document's base URL. Single-page navigation: the recommended model The previous example showed you how to create a link that performs a top-level navigation. That's fine for a webpage, but you shouldn't perform top-level navigation in an app for several reasons, including these: - The screen goes blank while the app loads the next page. - The script context is destroyed and must be initialized again. The app might receive system events but not handle them because the script context is being destroyed and reinitialized. Using single-page navigation provides better performance and provides a more app-like experience than top-level navigation. Navigation controls are not automatically provided in new Microsoft Visual Studio projects, so a top-level navigation to a new page means there's no way to get back to the first page unless you manually create a link or other navigation mechanism to go back. Also, your start page is the place to define how your app manages its life cycle—how it behaves when it starts up, shuts down, or is suspended. If you have multiple top-level pages, each one must contain logic for managing the app's life cycle and state. Which control should you use to bring content into your main page? - You can use the Document Object Model (DOM) to load documents from another source. - For simple HTML content (content that isn't interactive and doesn't contain script references), use an HtmlControl object. - For external web content, use the x-ms-webview control whenever possible. Compared with an iframe, this control provides better isolation, navigation, SmartScreen Filter availability, and support for sites that can’t be hosted in an iframe. - For all other content, use a Page control. Visual Studio provides several JavaScript project templates for Windows Runtime apps that can make managing navigation easier. These project templates provide a navigation control, called PageControlNavigator, that you can use to navigate between PageControl objects. The PageControlNavigator class demonstrates one way that you can use the PageControl to facilitate single-page navigation. The next steps show you how to create an app that contains multiple PageControl objects and how to use the single-page navigation model to navigate between those pages. Step 1: Create a new Navigation App project Start Microsoft Visual Studio 2013 Update 2.Note When you run Visual Studio for the first time, it prompts you to obtain a developer license. Choose File > New Project or click New Project from the Start Page tab. The New Project dialog box opens. In the Templates pane on the left, expand Installed => Templates => JavaScript => Store Apps. - Select the Universal Apps template type. The available project templates for JavaScript are displayed in the center pane of the dialog box. In the center pane, select the Navigation App (Universal Apps) project template. In the Name text box, type a name for your project. The examples in this topic use "NavigationAppExample". Click OK to create the project. Your new Navigation App project contains a start page, a home page, and some additional supporting files. It looks like this in Solution Explorer. Your new Navigation App project includes a number of files. Some are specific to a Windows app, some are specific to a Phone app, and some are shared. The project includes these HTML files: - default.html—the start page. It is loaded first. It contains an instance of the PageControlNavigator(which loads each page into the main window) and it's where you create your AppBar if your app uses one.Note HTML pages are loaded into a single content host, a div element declared in default.html. In default.html, the content host div element is declared as a control of type PageControlNavigatorusing the data-win-control attribute that is provided by Windows Library for JavaScript (WinJS). - home.html—the home page. It displays a "Welcome" title. The project includes these JavaScript files: - default.js—specifies how the app behaves when it's started. - home.js—specifies behavior that's associated with the home page. - navigator.js—implements the PageControlNavigatorobject that supports the navigation model for the Windows Store app JavaScript templates. The project includes these CSS files: - default.css—specifies Cascading Style Sheets (CSS) styles for the content host page and for the app as a whole. - home.css—specifies CSS styles for the home page. The project also includes the package.appxmanifest file, which describes the app package. Finally, the project also includes several image files, like splashscreen.png for the splash screen image, and storelogo.png, which is used for the Windows Store. Run the app. Choose Debug > Start Debugging, or choose F5 (choose SHIFT + F5 to stop debugging and return to Visual Studio). Here is a screen shot of the Windows app. Here is a screen shot of the Phone app. Notice that the content you're seeing isn't defined in the default.html file. It's defined in the home.html file, a separate page. It's the PageControlNavigatorthat retrieves the content of the home page and displays it inside default.html. The navigation control, PageControlNavigatoris shown here. It defines several functions that are used for navigation. This control is implemented in navigator.js. The constructor function performs initialization for the navigation control. A few important initialization tasks include setting handlers for WinJS events, such as the WinJS.Navigation.onnavigating event, and setting the home page of the app. (The home value is specified in the contenthostDIV element, in a data-win-options attribute.) A DIV element that's declared as the app's navigation control (in default.html) provides the content host for all of the app's pages. The DIV element uses the WinJS data-win-control attribute to declare itself as the navigation control, and this control provides the navigation model for the app. All page content is loaded into this DIV. Here's the complete markup for the default.html page. <!-- default.html --> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>NavigationAppExample</title> <!-- WinJS references --> <link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" /> <script src="//Microsoft.WinJS.2.0/js/base.js"></script> <script src="//Microsoft.WinJS.2.0/js/ui.js"></script> <!-- NavigationAppExample references --> <link href="/css/default.css" rel="stylesheet" /> <script src="/js/default.js"></script> <script src="/js/navigator.js"></script> </head> <body> <div id="contenthost" data-</div> <!-- <div id="appbar" data- <button data- </button> </div> --> </body> </html> This illustration shows the different units of content that appear in the app's window: In the next steps, you'll learn more about adding pages with the PageControlNavigator and the PageControl object. Step 2: Create a new page A PageControl is a modular unit of HTML, CSS, and JavaScript that functions as a logical page. When you add a new page to a Visual Studio 2013 project, you need to: - Add the new page using the Page Control item template in Visual Studio. - Add code to navigate to the new page by have to modify navigator.js. - Add UI and event handlers appropriate to your app, if necessary, to invoke the page-navigation code. A page has a set of predefined methods that the library calls automatically, in a predefined order. The WinJS.UI.Pages.define function exposes these methods for implementation. Add a page - In Solution Explorer, right-click the pages folder and choose Add > New Folder.Note For this example, we add a Shared page. You can add unique pages to the Windows or the Phone projects, as required. - Name the new folder page2. - Right click the page2 folder and select. Together, these files represent a logical page.Tip If you add the item template elsewhere in the project, you may need to update script and CSS references in page2.html. - Open page2.js and verify that the URI is correct in the define function. Here's what it should look like. Step 3: Customize your page Now, modify your new page so that it displays a different message and the day of the week. - Open page2.html. The Page Control item template creates an HTML page that contains a header section (which contains a back button) and a section for the page's main content. <>Content goes here.</p> </section> </div> </body> </html> - Replace the main content section with this one. Your page2.html file should now look like this. <>Page controls make it easy to divide your app into modular portions.</p> <p>Today is <span id="dayPlaceholder"></span>.</p> </section> </div> </body> </html> - Open page2.js. The PageControl includes a set of predefined functions that get called automatically, in a predefined order. The Page Control item templates include the ready function and updateLayoutand unloadfunctions for you. The PageControlNavigatorcalls the updateLayoutfunction when the user switches between portrait and landscape or changes the app windows size. This topic doesn't show you how to define the updateLayout, but it's something that every app should do. See Guidelines for resizing windows to tall and narrow layouts and Responsive design 101 for Universal Windows Platform (UWP) apps. The ready function is called when the page's DOM has been loaded, controls are activated, and the page has been loaded into the main DOM. (The PageControl supports additional functions for the page life cycle. For more info, see Adding Page controls.) Here's the page2.js file that the Page Control item template created. //. }, unload: function () { // TODO: Respond to navigations away from this page. }, updateLayout: function (element) { /// <param name="element" domElement="true" /> // TODO: Respond to changes in layout. } }); })(); Modify the ready function so that it retrieves the span you created in step 2 ("dayPlaceholder") and sets its innerText to the current day. //. var dayPlaceholder = document.querySelector("#dayPlaceholder"); var calendar = new Windows.Globalization.Calendar(); dayPlaceholder.innerText = calendar.dayOfWeekAsString(); }, unload: function () { // TODO: Respond to navigations away from this page. }, updateLayout: function (element) { /// <param name="element" domElement="true" /> // TODO: Respond to changes in layout. } }); })(); You've created and customized a page. In the next step, you'll enable the user who's running the app to navigate to your page. Step 4: Use the navigate function to move between pages When you run the app right now, it displays home.html; there's no way for the user to navigate to page2.html. A simple way to help the user get to page2.html is to link to it from home.html. <!-- home.html --> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> NavigationAppExample!</span> </h1> </header> <section aria- <p>Content goes here.</p> <!-- A hyperlink to page2.html. --> <p><a href="/pages/page2/page2.html">Go to page 2.</a></p> </section> </div> </body> </html> If you run the app and click the link, it seems to work: the app displays page2.html. The problem is that the app performs a top-level navigation. Instead of going from home.html to page2.html, it goes from default.html to page2.html. What you want instead is to replace the content of home.html with page2.html. Fortunately, the PageControlNavigator control makes performing this type of navigation fairly easy. The PageControlNavigator code (in your app's navigator.js file) handles the WinJS.Navigation.onnavigated event for you. When the event occurs, the PageControlNavigator loads the page specified by the event. The WinJS.Navigation.navigated event occurs when you use the WinJS.Navigation.navigate, WinJS.Navigation.back, or WinJS.Navigation.forward functions to navigate. You need to call WinJS.Navigation.navigate yourself instead of using the hyperlink's default behavior. You could replace the link with a button and use the button's click-event handler to call WinJS.Navigation.navigate. Or you could change the default behavior of the hyperlink so that when the user clicks it, the app uses WinJS.Navigation.navigate to go to the link target. To do this, handle the hyperlink's click event and use the event to stop the hyperlink's default navigation behavior; then call the WinJS.Navigation.navigate function and pass it the link target. Here's how to do that: - In your home.js file, define a click event handler for your hyperlinks. - Call the preventDefault method to prevent the default link behavior (which would navigate directly to the specified page). - Retrieve the hyperlink that triggered the event. - Call the WinJS.Navigation.navigate function and pass the link target to it. (Optionally, you could also pass a state object that describes the state of that page. For more information, see WinJS.Navigation.navigate.) - In the ready function in home.js, attach the event handler to your hyperlinks.); } }); That's the last step. Here's the complete code for your home.js file. // home.js (function () { "use strict";); } }); function linkClickEventHandler(eventInfo) { eventInfo.preventDefault(); var link = eventInfo.target; WinJS.Navigation.navigate(link.href); } })(); Run the app and click the link for page2.html. Here's what you see. This time the page is displayed using the proper navigation pattern. The Page control template includes a back button that is enabled when you use the WinJS.Navigation functions to navigate. When you use the WinJS.Navigation functions, the app stores navigation history for you. You can use that history to navigate backward by calling WinJS.Navigation.back or to navigate forward by calling WinJS.Navigation.forward. Saving navigation history when your app is suspended Navigation history is not automatically stored when your app is suspended or shut down, but it's easy to store this info yourself. Use the WinJS.Navigation.history property to retrieve the navigation history and use the WinJS.Application.sessionState object to store it. To ensure a smooth suspend/resume experience, it's best to store this info each time the user navigates. When your app resumes, retrieve the history info from the WinJS.Application.sessionState object and use it to set the WinJS.Navigation.history property. For an example of how to use the WinJS.Application.sessionState object to store and restore session data, see Part 2: Manage app lifecycle and state. For more info about suspending and resuming, see Launching, resuming, and multitasking. Summary You learned how to use objects and methods of the WinJS.UI.Pages namespace to support the single-page navigation model. You learned how to build apps using the single-page navigation model. You used the PageControlNavigator class, provided by the templates, to implement this model in your own app using PageControl objects and WinJS.Navigation features. Related topics - For developers - Your first app - Part 3: PageControl objects and navigation - Adding app bars - (Windows Store apps) - Making the app bar accessible
https://msdn.microsoft.com/en-us/library/windows/apps/hh452768.aspx
CC-MAIN-2017-09
refinedweb
2,715
51.24
Archived from ZwikiIssueTracker. Use that page for new comments. Nice, Simon! --SunirShah thanks Sunir. 4-dec-2001 17:15 Israel (via web too...): Excellent! I love the idea of a tracker within the ZWiki! but the ZCatalog instructions are kinda greek to me... I'll improvise on a throwaway wikiweb before I try it on my real one, and add my comments here if I succeed. if anyone can simplify/expand on stages 2 through 4 and specify minimal working version for stage 1 (I just got 0.9.8 so I guess I'm ok), I'll be really grateful! ...and more at 19:45 - I defined the meta-data, what indices do I need? I'm not sure I totally understand the issues with managing the ZCatalog. plus IssuePrototype? seems to have its source hidden... any help? :-) End of the day, tommorow I'll get on the ZWiki list, promise :) - I still can not get a copy of issue prototype. I am also not clear on the catalog business. Thanx - Daniel Daniel Mahler <mahler@cyc.com>, 2001/12/12 17:43 US/Pacific (via mail): It would be nice to integrate ZwikiIssueTracker with WikiMail. When somebody submits a bug, autoamtically subscribe them to the page generated for the issue. One could also add a process for assigning issues to resolvers: Initially a triage person is autoatically notified of each issue creation, and subscribed to each issue page. When the triage person assigns an actual resolver, the resolver is also subscribed. Daniel 2001/12/16 16:55 US/Pacific (via web): updated this and HowToInstallAZwikiCatalog - hope it helps 2001/12/17 01:19 US/Pacific (via web): Thanks This makes it a lot clearer. I am still having a few problems, but at least they are specific. - It seems like we now need to get the render_issuedtml method from somwhere. Where? - I cannot view any of the pages I have created. The main Tracker page complains about sort_order(despite appearances, I am using Zope-2.4.3 - I patched the original source directory): Simon Michael <simon@joyful.com>, 2001/12/17 13:31 US/Pacific (via mail): > 1. It seems like we now need to get the render_issuedtml method from > somwhere. Where? zwiki 0.9.8 > 2. I cannot view any of the pages I have created. The main Tracker > page complains about sort order ... > Error Type: KeyError? > Error Value: sort_order It seems to be from this code in the Tracker page: _.getattr(REQUEST,'sort_order','') I don't know how this can cause a keyerror - it doesn't on the zope/python combinations I've tried - but I think you are not the only one seeing this problem. Daniel Mahler <mahler@cyc.com>, 2001/12/17 13:51 US/Pacific (via mail): 206.184.139.140 writes: > ++added: > It seems to be from this code in the Tracker page:: > > _.getattr(REQUEST,'sort_order','') > That's what I figured. I even tried setting a sort_order string property on both the page and on the whole wiki, with no effect: > I don't know how this can cause a keyerror - it doesn't on the > zope/python > combinations I've tried - but I think you are not the only one seeing > this > problem. The GetattrProblem? is either an instance of the same thing or something very similar. Daniel anon just think an instant instead of moaning _.getattr(REQUEST, sort_order, '') GetAttribute? sort_order FROM REQUEST so ? as you're debugging this frigging mess, just add ?sort_order=value to your url AND sort_order is the sorting attribute to dtml-in tags, it's only an matter of presentation. if it crash your work, and you don't know why, just comment it out or trash all references to it 2002/02/19 22:01 GMT (via web): How can I copy three pages needed to setup a WikiTraker?? (ZWikiTracker?,AddIssue?,IssuePrototype?) When I try I only get pages as they are in this wiki Thanks Robert@recor.ch Simon Michael <simon@joyful.com>, 2002/02/20 16:27 GMT (via mail): To copy the source, click edit this page on this site and copy from there. Paste that into the corresponding edit form on your site. Then you may need to adjust the page type etc. as described elsewhere. anon I can't edit the source for AddIssue? to grab it, and I don't know what defaults are used for issue_categories, issue_severities, issue_statuses. help? Maybe ('user-browsing', 'user-editing', 'user-editing-stx', 'user-editing-rst', 'user-editing-moin', 'user-editing-wwml', 'user-editing-plaintext', 'user-editing-html', 'user-editing-epoz', 'user-editing-extedit', 'user-editing-stxlatex', 'user-pagehierarchy', 'user-rating', 'user-mail', 'user-issuetracking', 'user-dtmlscripting', 'user-fittests', 'user-purplenumbers', 'admin-installing', 'admin-configuring', 'admin-customizingskins', 'admin-defaultcontent', 'general-i18n', 'general-plone', 'general-skins', 'general-docs', 'general', 'site-zwiki.org', 'site-plone.zwiki.org', 'site-zopewiki.org', 'other')..? SM This site's current issue_severities: critical serious normal minor wishlist issue_categories: don't know zwiki: installation zwiki: general zwikidotorg template zwiki.org zwiki tracker other issue_statuses: open pending closed anon Cool; thanks. I get a Zope error on this page: Zope Error Zope has encountered an error while publishing this resource. Error Type: KeyError?? Error Value: sort_order PB I am flattered. However, the main feature of IssueTracker (formally named SiteTracker?) is its simplicity. It was originally built for visitors of a website to use and if a visitor is going to spend the time you want to make it as simple as possible for them. I shall study this product closely to see if I can learn something from it to my benefit. Perfect! SimonMichael, 2002/04/08 03:05 GMT (via web): Thanks for the feedback Peter. I think it's about as simple as the original SiteTracker? I looked at - same basic UI features - am I wrong ? It may seem otherwise because of the wiki stuff going on around it ? 2002/04/19 22:16 GMT (via web): Is this up to date for 0.9.9? warning, this is probably out of date. Bring your wellington boots. Simon, 2002/05/21 18:33 GMT (via web): Integrated AddIssue?'s form & issue creation code into ZwikiIssueTracker. You can update your [zwikidir/Extensions/mailin.py]? (like this ) and get rid of AddIssue? if you like. 2002/06/24 23:09 GMT (via web): I had to add in a lastEditTime index -- docs should be updated, or dtml/html on tracker page, that is. Simon Michael, 2002/06/28 00:32 GMT (via mail): Updated the index & metadata lists on HowToInstallAZwikiCatalog . Simon, 2002/08/11 22:54 GMT (via web): Installation instructions changed above - the issueprototype page is no longer required. DeanGoodmanson, 2002/09/18 01:20 GMT (via web): Added some information to the Install text. Copying FilterIssues is also helpful. Especially helpful for stealing the code from the Frontpage for the links. In the front page it may make sense to put the dtml-let numissues be just around the latest bugs block. page. WimBekker, 2002/09/18 15:00 GMT (via web): Where do I put issue_.. variables? DeanGoodmanson, 2002/09/18 16:32 GMT (via web): Wim - Put your issue_* properties in your wiki's folder properties. WimBekker, 2002/09/23 10:49 GMT (via web): Ok, it's running, thanks to point 3 above! Next question, if I inspect an issue, I have the page with the '<<', ^^ and >>. But the ^^ links to ZwikiIssueTracker and mine tracker has another name. How can I change the link? Simon, 2002/09/23 16:07 GMT (via web): It's hard-coded in Tracker.py, you'll have to change it there. Congrats on getting it working, by the way. I don't hear that too often. DeanGoodmanson I added a bunch of lines in the online ZWikiTracker? page noting which lines need be commented, perhaps I forgot similar comments in FilterIssues ? DeanGoodmanson, 2002/10/07 05:01 GMT (via web): What is the line < dtml-var title missing html_quote> in the "Issue title:" section for? For me it puts the page name (BUGTracker?) in the title of the Bug, which (I think) trounced . More later. BillSeitz, 2002/11/20 (via web): re 9/23 comments, I have a similar but more nasty problem. When adding a new issue I get an error message because it seems to be posting to ZwikiIssueTracker instead of my pagename (IssuesView?). But the issue actually gets added anyway. (I see ZwikiIssueTracker hard-coded in mailin.py - is that the issue (even though I haven't done anything to turn on mail features)?) Never mind, I found the redirect DTML code the ZwikiIssueTracker page (that even had a comment sayng it needed to be renamed, doh!). All working now. But this raises the question: why do the instructions say to use a different name for the form, if it's going to be hard-coded in various places anyway! I would recommend that a new name be used everywhere (I'd vote for IssueTracker something like that), so that the hard-coding can be left as is for now. SimonMichael, 2002/11/21 18:32 GMT (via web): Hi Bill - I agree with you, what are these developers playing at. Ok, I'm renaming this site's tracker page to IssueTracker. I'll still call the implementation ZwikiIssueTracker. Simon, 2002/04/08 23:36 GMT (via web): Turned off the header/footer on the main tracker pages to see how it works out. DeanGoodmanson, 2002/10/03 14:37 GMT (via web): I am very interested in ZwikiIssueTracker . I see a large number of feature requests, and a few bugs. - What's the current approach for development: From re-write in ZPT, Fix bugs add features, or wait for contributor? - Is it used much beyond Zwiki? Enough interest for a ZwikiDiscussion ? SimonMichael, 2002/12/05 19:37 GMT (via web): I renamed ZwikiIssueTracker -> ZwikiIssueTracker -> IssueTracker as promised. Seems to have been painless.. I replaced the ZwikiIssueTracker name in mailin.py and the tracker page dtml. Also fixed a small bug with the new issue title field. ZwikiIssueTracker has lots of backlinks, but I think most of them will make sense - change ZwikiIssueTracker links to IssueTracker wherever it seems needed. DeanGoodmanson, 2002/12/05 20:47 GMT (via web): IssueTracker page changed I'd like to modify IssueTracker to be a purely copy/pastable page. First by making all references to ZWiki links RemoteWikiLinks, well, that's all I can think of for now. I think most of the other stuff was related to teh page name itself. Nifty job chucking the comment area. DeanGoodmanson, 2002/12/06 06:47 GMT (via web): IssueTracker changes Very glad for the page name change. My previous implementation annoyances are now only in the previous statement. (Haven't check FilterIssues or FrontPage yet, though.) Here's my suggestion for the following block in IssueTracker: This is the ZWiki bug database. The last ten issues modified are shown by default. To perform more advanced search queries visit FilterIssues, and for more search help see ZWiki:TrackerSearchTips. For issues you will probably hit when implementing a ZWiki visit ZWiki:IssueTracker and ZWiki:KnownIssues. For discussion and more information on this tool visit ZWiki:ZwikiTracker. Other related bug lists: zope bugs, debian zope-zwiki bugs and ancient ZWiki:ZwikiProblems. Toni Arnold, 2002/12/08 22:01 GMT (via web): Installation of an IssueTracker is annoying, so I automatized it with a SetupIssueTracker? script. DeanGoodmanson, 2002/12/09 02:39 GMT (via web): AdminHowtos Thank you !!! Hopefully later this can be seperated for two other seperate parts: Set a Catalog, Setup an IssueTracker Toni, Have you had other IssueTracker type extension thoughts for ZWiki? Your input at ZwikiRecordBook would be appreciated. Your code helps this effort also. SimonMichael, 2002/12/09 21:36 GMT (via web): Nice one Toni - this brings #267 simpler catalog setup/268 much closer. I hope to offer these as options on the add zwiki web form. DeanGoodmanson, 2003/01/06 02:54 GMT (via web): Did you use regulations to hide the comment box? SimonMichael, 2003/01/07 14:11 GMT (via web): Permissions, yes. I disable add comments permission on the tracker page to make it simpler. Test FlorianKonnertz, 2003/01/11 09:46 GMT (via web): Installed tracker without problems on Zope-2.5.0, Zwiki-0.13.1, (manually); - Cool! Some examples and experience reports how to use it in certain environments (company intranet, ProjectManagement?, TodoLists?) would be good to have. I gonna see if it's useful to shift to the tracker from my current todolists and report. TrackerDiscussion? , refactoring --FlorianKonnertz, 2003/02/02 06:14 GMT What about an extra TrackerDiscussion? page. I'd like to add some info about tracker usage in SubWiki-s, but it's not clear where the DocumentMode? stops and the ThreadMode? begins, so i'd do some refactoring if you also want. RefactorMe --FlorianKonnertz, 2003/02/05 08:36 GMT RefactorMe 2003/02/06 20:52 GMT Here is a comment Inside of Plone? --JMR Sat Feb 8 15:13:16 CST 2003 Does the issue tracker work inside an CMF environment like plone? Installed OK, can't add any issues --JBD 2003-03-18 14:26 CST Clean Zope 2.6.1, Zwiki 0.16.0 using setupIssueTracker script (very nice!) When I try to add an issue I get a KeyError?: ZWiki.Tracker, line 161, in CreateIssue?. Anybody know what might be wrong? Installed OK, can't add any issues --SimonMichael, 2003/03/18 20:53 GMT Note tracker code is in flux at the moment. Use the code in ZWiki/content/tracker/IssueTracker.stxdtml for your tracker page, not this site's IssueTracker which requires the latest zwiki-cvs. issue tracking resources --DeanGoodmanson, 2003/03/20 15:06 GMT Good article on Issue Tracker etiquite: Thanks to [Roundup]? blog : ZwikiIssueTracker upgraded --SimonMichael, 2003/03/21 23:22 GMT I think the tracker changes for 0.17 are complete. Bugs have been squashed, there are no more issuedtml pages on this site, and upgrade issues have been worked out. AdminHowtos has some notes, if you have a tracker I'd like to know if they match your experience. One unforeseen consequence of all this: changing an issue description (used to be "title") in a big wiki is now much slower, because it means a page rename. It's issue 474 if you find a solution. Otherwise, it seems to have all worked out well. AttributeError? --FlorianKonnertz, 2003/03/22 14:43 GMT I upgraded today to 0.17cvs, latest tracker and filterissues code, i updated my catalog and did the upgradeAll action, and now get the following error - do you have any ideas: Traceback (innermost last): * Module ZPublisher.Publish, line 102, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 43, in call_object * Module Products.ZWiki.ZWikiPage, line 215, in __call__ * Module Products.ZWiki.ZWikiPage, line 227, in _render * Module Products.ZWiki.ZWikiPage, line 399, in render_stxprelinkdtmlfitissuehtml AttributeError: hasFitTests AttributeError? --SimonMichael, 2003/03/25 00:12 GMT Ah.. the main code assumes hasFitTests but it wasn't defined if you don't have fit installed. cvs update Fit.py now and it should work, thanks. appending comments to issue property change. --DeanGoodmanson, 2003/04/04 04:25 GMT Code change: def changeIssueProperties(self, title=None, category=None, severity=None, status=None, note=None, REQUEST=None ): """ Change an issue page's properties and redirect back there. Less flexible but more secure than changeProperties. It expects title to be the issue description, not the complete page name. Changing this will trigger a page rename, which may be slow. XXX security: allows title/category/severity/status properties to be set without Manage properties permission. """ comment = "" if title: # title # XXX upgrade issue: if they have not yet upgraded to # 0.17-style issue page ids, this will mess things up. comment += "Title changed from:"+self.title_or_id()+" to:" # this one may go? title = self.getId()[:11]+' '+title self.rename(title,updatebacklinks=1,sendmail=1,REQUEST=REQUEST) comment += title+" ... " if category: comment += "\nCategory changed from:"self.category+" to:"+category+" ... " self.manage_changeProperties(category=category) if severity: comment += "\nSeverity changed from:"+self.severity+" to:"+severity+" ... " self.manage_changeProperties(severity=severity) if status: comment += "\nStatus changed from:"+self.status+" to:"+status+" ... " self.manage_changeProperties(status=status) if not note: note = "Property change." self.comment(text=comment, use_heading=1, subject_heading=note, REQUEST=REQUEST) self._setLastEditor(REQUEST) self.reindex_object() if REQUEST: REQUEST.RESPONSE.redirect(self.page_url()) Form change:: Note: IssueTracker change --DeanGoodmanson, 2003/04/04 04:27 GMT Well that got messed up. Sorry...here it is again. NOTE: THIS CODE HAS NOT BEEN RAN, LET ALONE TESTED! detail page change : <b>Note:</b> <input type="text" name="note" value="" size="55" maxlength="55"> IssueTracker change --SimonMichael, 2003/04/04 06:44 GMT Hmm.. like that ? Nice one!! Let's play with it. next prev , top links in issue view: << ^^ >> --DeanGoodmanson, 2003/04/04 19:10 GMT These look to be dropped in the latest incarnation. When my peer noted that the ^^ were links to "ZwikiIssueTracker", the discussion concluded with: These navigation links are not needed (and may be mis-understood when jumping for a filtered list) but having a link back to the main IssueTracker page is important (previous ^^). next prev , top links in issue view: << ^^ >> --SimonMichael, 2003/04/04 19:41 GMT I've been wondering where those went.. I agree, some easy link back to IssueTracker (that works in simple/minimal mode) is useful. next prev , top links in issue view: << ^^ >> --SimonMichael, 2003/04/04 19:54 GMT But, hard-coding a link to IssueTracker doesn't seem like the answer. Could link to the (first) parent, but that seems a bit confusing. So I'm not sure how to improve it. next prev , top links in issue view: << ^^ >> --DeanGoodmanson, 2003/04/04 21:56 GMT >> hard-coding a link to IssueTracker doesn't seem like the answer. Yes, but can it wait until the bigger issues (multiple trackers/wiki) get addressed? For a user savvy (or obscure) enough to not use IssueTracker as their main tracker page (which I wouldn't recommend, based on default FilterPages? and FrontPage tracker views), they'll probably be using something with a heirarchy (we plan to, even in simple mode)... With all that, my recommendation if you want to bother to put it in: Don't display it if the page doesn't exists, similar to the edit page's TextFormattingRules. Closing thought: Why do I have a sudden urge to go an ASCII art exhibition this weekend? tracker upgrade notes --DeanGoodmanson, 2003/04/08 02:53 GMT I had to recatalog (clear and find) after upgrading (upgradeAll) to get my issue pages to be recognized. Bad news without it--multiple IssueNo001?'s. The FrontPage code from the past needed more work than changing the catalog lookup. Easily rectified by grabbing the latest from here. The isIssue implicit property was a bit confusing, but I haven't grokked catalogs yet. The method was enlightening. I attempted to dtml-ify the "last 5 changes", filterissues, adn issuetracker with mixed success. a. Wanted to put it in /wiki/support, but coudln't figure out dtml-var wiki.support.method calls, and didn't want to dtml-with it, so ended up putting them as filterissues_dtml names in wiki. Lost STX formatting and wikilinking,without regret, and added a couple of wikilink calls for the headers. (b.horribley tried it as a wikipage from the Add a Zwiki Page menu...gave up quick) c. What's the trick to passing in the number of items to the "last five issues" method? I can deal with/without the value when I get it, but can't figure out how to pass it in. Detail pages seem to render in a similar speed as before, while IssueTracker and Filter issues are much faster (about as long as a detail page.) Strange crash --DeanGoodmanson, 2003/04/16 14:18 GMT I haven't found much information about a "guarded item" crash, but seem to be experiencing it when trying to Add a string field to each issue and add a couple of statuses. I've made the appropriate (duplicate the pattern) changes to Tracker.py, folder properties, each tracker page (added property), and Catalog (added fields/metadata,toasted recycle_bin objects, cleared & re-found), yet I get the following traceback on an original IssueTracker page. Note: On other wikis in the same server that have only had the tracker.py and new field added, the "old" page support does not crash. Heres the old IssueTracker crash with the updates above : File /Zope251/lib/python/DocumentTemplate/DT_Let.py, line 76, in render (Object: open="_.len(Catalog(isIssue=1,status='open'))" pending="_.len(Catalog(isIssue=1,status='pending'))" closed="_.len(Catalog(isIssue=1,status='closed'))" tracked="open+pending+closed") File /Zope251/lib/python/DocumentTemplate/DT_In.py, line 695, in renderwob (Object: issue_statuses) File /Zope251/lib/python/DocumentTemplate/DT_Util.py, line 159, in eval (Object: _[_['sequence-item']]) (Info: _) File <string>, line 2, in f File /Zope251/lib/python/AccessControl/DTML.py, line 32, in guarded_getitem (Object: IssueTracker) File /Zope251/lib/python/AccessControl/ZopeGuards.py, line 90, in guarded_getitem KeyError My next step is to flush cache and upgradeAll to clear pre-renders. (right?) Anything else I should do? strange crash-source found --DeanGoodmanson, 2003/04/17 14:03 GMT By removing the section open/pending/closed and open/total sections I was able to render and get around my problem with also removing this code: <dtml-let As FilterIssues gathers the same information I'm going to try to gather it that way. python script. For use with IssueTrackerZPT. --FlorianKonnertz, 2003/04/17 15:10 GMT I extracted the catalog query part as a python script. For use with IssueTrackerZPT. - just FYI. FogBUGZ? sounds very nice --simon, 2003/04/26 20:45 GMT , mentioned on ZwikiScrumDiscussion. To read: . Lots in common with ZwikiIssueTracker, and should be mined for ideas. See also CVSTrac?. Strange crash --Simon Michael, 2003/04/26 20:51 GMT zwiki-wiki@zwiki.org (DeanGoodmanson) writes: > a couple of statuses. I've made the appropriate (duplicate the pattern) > changes to Tracker.py, folder properties, each tracker page (added Did you update your issue_statuses folder property ? You can tell (pretty much) from the traceback that's what it's complaining about. It's got a sequence-item that doesn't exist in issue_statuses. So either issue_statuses needs something added, or your loop is coming up with unexpected items. You could also try putting the offending line inside dtml-try, and in the except clause print sequence-item and anything else interesting (these may be in angle brackets so you may need to view source). subtopics: ... -- 2003/07/31 20:55 GMT, I get: <pre> NameError Sorry, a site error occurred. Traceback (innermost last): File C:\Usr\ZOPEDE~1.1\lib\python\ZPublisher\Publish.py, line 150, in publish_module File C:\Usr\ZOPEDE~1.1\lib\python\ZPublisher\Publish.py, line 114, in publish File C:\Usr\ZOPEDE~1.1\lib\python\Zope\__init__.py, line 159, in zpublisher_exception_hook (Object: wiki) File C:\Usr\ZOPEDE~1.1\lib\python\ZPublisher\Publish.py, line 98, in publish File C:\Usr\ZOPEDE~1.1\lib\python\ZPublisher\mapply.py, line 88, in mapply (Object: IssueTracker) File C:\Usr\ZOPEDE~1.1\lib\python\ZPublisher\Publish.py, line 39, in call_object (Object: IssueTracker) File C:\Usr\ZOPEDE~1.1\lib\python\OFS\DTMLDocument.py, line 127, in __call__ (Object: IssueTracker) File C:\Usr\ZOPEDE~1.1\lib\python\DocumentTemplate\DT_String.py, line 473, in __call__ (Object: IssueTracker) File C:\Usr\ZOPEDE~1.1\lib\python\DocumentTemplate\DT_Let.py, line 75, in render (Object: Catalog="_.getattr(folder(),getCatalogId())") File C:\Usr\ZOPEDE~1.1\lib\python\DocumentTemplate\DT_Util.py, line 159, in eval (Object: _.getattr(folder(),getCatalogId())) (Info: folder) File <string>, line 2, in f NameError </pre> Any suggestions? -roy ... --DeanGoodmanson, 2003/08/01 01:04 GMT reply Roy - Try emptying your recycle_bin folder, then empty and re-catalog your catalog. ... -- 2003/08/01 15:57 GMT reply Nope, didn't do the trick. Any other suggestion? -roy IssueTracker inside Plone Site problem? -- Mon, 25 Aug 2003 21:57:57 +0000, which is inside a Plone site I get: Site Error An error was encountered while publishing this resource. Sorry, a site error occurred. Traceback: (snipped) IssueTracker inside Plone Site problem? --simon, Mon, 25 Aug 2003 23:51:52 +0000 reply Yes, we have an open issue on this.. the default plone catalog lacks certain indexes and metadata that IssueTracker relies on. Here it's complaining about a missing index. IssueTracker inside Plone Site problem? --simon, Mon, 25 Aug 2003 23:54:08 +0000 reply PS you can try to figure out what it needs and add them by hand in the ZMI. This will be automated when possible. setupTracker feedback -- Sun, 21 Sep 2003 21:11:19 -0700 reply I just got a 0.23CVS and setup via SOMEPAGEURL/setupTracker (Zope 2.7b1). Seems OK except that the catalog was empty after I created it. Because of this, FuzzyUrlMatching? didn't work until the catalog was populated also. - DeanG setupTracker feedback --Simon Michael, Tue, 23 Sep 2003 00:11:30 -0700 reply Thanks for testing Dean - good point, we should make it do a catalog find as the last step. Problem with issue_colours -- Thu, 06 Nov 2003 15:39:45 -0800 reply If you include issueColour as a metadata entry on your zwiki Catalog (as suggested in this page and on ZwikiAndZCatalog) the mechanism for overriding the issue colours doesn't work. You're supposed to be able to establish your own issue color scheme via a issue_colours lines property on your zwiki folder. This didn't work for me unless I removed the issueColour metadata from the catalog. I think it has to do with namespace - i.e. DTML references to issueColour would hit the object property established by the Catalog first, instead of bottoming out in the Tracker.Py function as intended. Problem with issue_colours -- Thu, 06 Nov 2003 15:49:21 -0800 reply Also - on the whole I'm disappointed with Zwiki's chronic use of explicit style formatting. I've had to touch far too many files in an effort to apply consistent CSS usage while customizing my Zwiki. This relates to the issue_colours problem because even now that I fixed it, it's an ungainly mechanism. I should not be putting raw color codes into my top-level zwiki folder properties. That's just wrong. That's what the stylesheet is for. Now that I've got it working, I plan on adapting it to use class markers instead of bgcolor. Problem with issue_colours --simon, Sun, 30 Nov 2003 13:33:16 -0800 reply That's a good idea (styles for issue colours). Error on "Add issue" -- Sat, 20 Dec 2003 08:59:31 -0800 reply This wiki's issuetracker template gave an error. Traceback (most recent call last): File "/usr/local/zope/instance/Products/ZWiki/UI.py", line 538, in issuetracker body = default_issuetrackerdtml.__of__(self)(self,REQUEST) File "/usr/local/zope/2.6.1/lib/python/App/special_dtml.py", line 61, in __call__ (self,)+args[1:],kw) File "/usr/local/zope/2.6.1/lib/python/DocumentTemplate/DT_String.py", line 474, in __call__ try: result = render_blocks(self._v_blocks, md) File "/usr/local/zope/2.6.1/lib/python/DocumentTemplate/DT_Let.py", line 76, in render return render_blocks(self.section, md) File "/usr/local/zope/2.6.1/lib/python/DocumentTemplate/DT_Util.py", line 201, in eval return eval(code, d) File "", line 0, in ? File "/usr/local/zope/instance/Products/ZWiki/Tracker.py", line 215, in createIssue self.create(pageid,text=text,REQUEST=REQUEST) File "/usr/local/zope/instance/Products/ZWiki/Editing.py", line 58, in create raise 'Unauthorized', ( Unauthorized: You are not authorized to add ZWiki Pages here. -Trevor Error on "Add issue" --SimonMichael, Tue, 23 Dec 2003 01:28:36 -0800 reply Give yourself Zwiki: add pages permission. ZWikiTracker? 0-26-0 Setup problem -- Mon, 05 Jan 2004 13:41:01 -0800 reply Hi, I'm a Zwikki Newbie and I've just installed ZWiki 0-26-0 y URL ""(really the loopback interface). I try to run "" and it created a Zwiki page with id="setupTracker".... What's the problem? ZWikiTracker? 0-26-0 Setup problem --Simon Michael, Tue, 06 Jan 2004 02:58:54 -0800 reply It should be IssueNo? RemoteWikiLink? shortcut --DeanGoodmanson, Sun, 01 Feb 2004 17:14:45 -0800 reply Quick test to see how this works... IssueNo:0001 IssueNo? RemoteWikiLink? shortcut --DeanG, Mon, 02 Feb 2004 07:06:10 -0800 reply Of course! RemoteWikiLinks work on Plain Text pages. I didn't expect that. The IssueNo? page worked as I hoped, but getting parameter parsing in the page doesn't work as I can't save it in DTML mode. Use of prefix "Issue" for page names --Alan Cowderoy, Tue, 23 Mar 2004 05:41:15 -0800 reply This discussion has been refactored as #761 different prefix for issue page names. IssueNo? RemoteWikiLink? shortcut --SimonMichael, Mon, 24 May 2004 03:36:20 -0700 reply IssueNo? is no longer considered an issue. issue pages begin with numbers ? --SimonMichael, Mon, 24 May 2004 03:37:19 -0700 reply What do you think of the example at the end of #761 different prefix for issue page names ?
http://zwiki.org/OldZwikiTrackerDiscussion
CC-MAIN-2017-13
refinedweb
4,937
58.99
XML Editor IntelliSense Features The XML Editor provides full IntelliSense features comparable to other language editors provided in Visual Studio. This section explains how you can use the IntelliSense with XML Schema definition language (XSD) and XSLT documents. IntelliSense in an XSD Document After a schema is associated with your document, you get a drop-down list of expected elements any time you type "<" or click the Display an Object Member List button on the XML editor toolbar. For information about how to associate schemas with your XML documents, see XML Document Validation. When you type SPACE from inside a start tag, you also get a drop-down list showing all attributes that can be added to the current element. When you type "=" for an attribute value, or the opening quote for the value, you also get list of possible values for that attribute. Values are only provided if the schema provides enumerated values via xsd:enumeration facets, or if the attribute is a Boolean type. An IntelliSense list of known language codes is also provided for xml:lang or any simpleType that derives from xsd:language. An IntelliSense list of known targetNamespace values is provided for namespace declarations. An IntelliSense list of possible values is also provided when you type ">" to close a start tag if the element is a simpleType. The behavior for elements is similar to the behavior for attributes described in the previous paragraph. ToolTips also appear on these IntelliSense lists based on xsd:annotation and xsd:documentation information found in the associated schema. IntelliSense in an XSLT Document After you add a named template or an attribute to your XSLT document, you can use IntelliSense to insert the following: Attribute set names. Template modes. Template names. Parameter names for a given mode. Parameter names for a given named template. For more information, see Walkthrough: Using XSLT IntelliSense topic. Auto-Completion The XML editor also makes editing XML easier by filling in required XML syntax for you. For example, if you type the following start tag: <book> The XML editor fills in the end tag and positions the cursor after the start tag. The following is an example of this (the "|" notes the cursor position): <book>| </book> Because attribute values must always have quotes, the XML editor fills in the quotes for you. For example, if you type the following: <book title= The XML editor adds the quotes and positions the cursor between the quotes: <book title="| " Similarly, the XML editor also inserts the following XML syntax automatically for you: End a processing instruction: ?> End a CDATA block: ]]> End a comment: --> End a DTD declaration: > The XML Editor also has the ability to insert a namespace declaration if you select a namespace qualified element or attribute from an IntelliSense list and the namespace for that element or attribute is not yet in scope. For example, if you select the e:Book element from the IntelliSense list where the prefix is bound to the namespace that has not been declared in the document, the XML editor inserts the required namespace declaration for you. The following is the resulting XML text: <e:Book xmlns:e="" Brace Matching The XML editor provides brace highlighting to give you immediate feedback on elements you have just closed. You can also use the keyboard shortcut (CTRL+]) to jump from one brace to the matching brace. The XML editor does this for the following items: Matching start and end tags. Any pair of "<" or ">" angle brackets. Start and end of comments. Start and end of processing instructions. Start and end of CDATA blocks. Start and end of DTD declarations. Opening and closing quotes on attributes. Modifying the IntelliSense Options The IntelliSense and auto-completion features are enabled by default. However, you can change this by modifying your Tools-Options settings. The Auto Insert section of the Miscellaneous page controls the following behavior: To change the auto-completion behavior Select Options from the Tools menu. Expand Text Editor, expand XML, and select Miscellaneous. Make any changes to the Auto insert section and click OK.
https://msdn.microsoft.com/en-us/library/ms255811(v=vs.100).aspx
CC-MAIN-2015-32
refinedweb
680
52.7
Installed extensions are JAR files in the lib/ext directory of the Java Runtime Environment (JRE™). The JRE is a strict subset of the JDK: public final class RectangleArea { public static int area(java.awt.Rectangle r) { return r.width * r.height; } } This class has a single method, area, that takes an instance of java.awt.Rectangle and returns the rectangle's area. Suppose that you want to test RectangleArea with an application called AreaApp: import java.awt.*; public class AreaApp { public static void main(String[] args) { int width = 10; int height = 5; Rectangle r = new Rectangle(width, height); System.out.println("The rectangle's area is " + RectangleArea.area(r)); } } This application instantiates a 10 x 5 rectangle, and then prints out the rectangle's area using the RectangleArea.area method. Let's first review how you would run the AreaApp application without getting a runtime exception. If area.jar was in the directory /home/user, for example, you could use this command: java -classpath .:/home/user/area.jar AreaApp The class path specified in this command contains both the current directory, containing AreaApp.class, and the path to the JAR file containing the RectangleArea package. You would get the desired output by running this command: The rectangle's area is 50 Now let's look at how you would run AreaApp by without needing to specify the class path: java AreaApp Because you're using area.jar as an installed extension, the runtime environment will be able to find and to load the RectangleArea class.
http://docs.oracle.com/javase/tutorial/ext/basics/install.html
CC-MAIN-2014-52
refinedweb
256
56.25
You can subscribe to this list here. Showing 4 results of 4 09:02:26AM -0700, Neil Watkiss wrote: | 4.3.5 |^html is a 404. | Did you mean '#', not '$'? The above URI is not intended to be a general HTTP URL with a #fragment Instead, this example is intended to demonstrate how XML namespace/name pair (qname) can be encoded as a YAML type family. The suggested mapping is to take the XML namespace and appending $ and then appending the XML tagname. Since XML namespaces are valid URIs, and since $ is a valid URI character, and since XML tagnames (mod ascii) are also valid within a URI, the result is a valid URI, and thus a YAML type family. Furthermore, since the dollar sign($) is not a valid character for XML tag names, this is even a reversable mapping! Thus, the example demonstrates how one could encode XML qualified names using the YAML type family mechanism; for a proper XML mapping, what remains is a method to map attributes/elements on to the structural constraints of YAML (Don Park's rythemic embedding is one possiblity; relax's element/attribute ismorphism is another ) Perhaps this example should be framed better to that the intent is more transparent, or it should be removed altogether to avoid confusion? | [Of course, this is just nits in the _spec_. I haven't worked through the | structural changes themselves.] The structural changes are bound to have a few bugs in them. Thank you so much for your careful review. ;) Clark -- Clark C. Evans Axista, Inc. 800.926.5525 XCOLLA Collaborative Project Management Software Oren Ben-Kiki [25/06/02 17:14 -0400]: > :-). Some nits: 4.3.5^html is a 404. Did you mean '#', not '$'? Actually, that's all I can spot right now. It looks really very good! [Of course, this is just nits in the _spec_. I haven't worked through the structural changes themselves.] Later, Neil YAML.pm version 0.35 is on the CPAN now. This version reflects many of the changes in the spec, adds over 200 new tests, and dumps even more Perl data structures. Enjoy. Clark, please add this to the YAML front page. Cheers, Brian PS Could we change the refcard colors from grey on gray to black on white?
http://sourceforge.net/p/yaml/mailman/yaml-core/?viewmonth=200206&viewday=27
CC-MAIN-2014-52
refinedweb
383
75.81
Hi Tim,I want to use 12 sensors, which is obviously achievable with your code, I have got 6 working really well so far so thank you.... however there are only 12 pins on the arduino uno, so I can only use 6 sensors (obviously 2pins per sensor). I see you can buy a Mux shield to add more inputs. Would this shield work with your code? (I'm very new to code). Would I need to change the code much to make it work? or is there a better / easier option?Thanks again Brilliant, thanks Tim, just tried that and it works fine with 1 sensor, I am using HC-SR04's.... much better than buying more bits!!Now I just need to figure out how to combine this code with the NewPing15sensor code to make it work with more sensors, any ideas, is it easy to do?I am needing to increase the number of sensors as I want to make sure that proximately to the speakers does not trigger sounds (so no one goes deaf!)I am making an installation as part of a final piece for an MA, i'd be happy to send details and photos when its all up and running...thanks againandre #include <NewPing.h>#define SONAR_NUM 12 //(2, 2, MAX_DISTANCE), // Using same pin for trigger and echo. NewPing(3, 3, MAX_DISTANCE), NewPing(4, 4, MAX_DISTANCE), NewPing(5, 5, MAX_DISTANCE), NewPing(6, 6, MAX_DISTANCE), NewPing(7, 7, MAX_DISTANCE), NewPing(8, 8, MAX_DISTANCE), NewPing(9, 9, MAX_DISTANCE), NewPing(10, 10, MAX_DISTANCE), NewPing(11, 11, MAX_DISTANCE), NewPing(12, 12, MAX_DISTANCE), NewPing(13, 13, MAX_DISTANCE)}; After the substitution of the tone function with the toneWorkaround one and the change of the power supply of the PING))) (attached to A4) to getting it's power from the Arduino everything is working juuuust fine!!!I am now using the ping_median for the pings just in case there is some interference.Thanks again for the great library.basile I've downloaded the v1.5 and tried it in arduino 1.0 but it wont compile. im using a cloned arduino board with atmega8. does it support older boards? is the board im using. First, thanks for the lib! I love it. Second I will apologize in advance if this has already been asked, but I can't seem to search just this topic so I may have missed it, if it was. Has any one else experienced an error when attempting to use tone() along with this lib? Has any one else experienced an error when attempting to use tone() along with this lib? When I attempt to include tone [e.g. tone(11,1000,20)] I get an error: core.a(Tone.cpp.o): In function `__vector_7':C:\Users\Dave\arduino-1.0.1-windows\arduino-1.0.1\hardware\arduino\cores\arduino/Tone.cpp:523: multiple definition of `__vector_7'NewPing\NewPing.cpp.o:C:\Users\Dave\arduino-1.0.1-windows\arduino-1.0.1\libraries\NewPing/NewPing.cpp:214: first defined here I have a HC-SR04 sensor, a 3.3v capable bluetooth module, and an Arduino Uno r3 (that is it besides spares of all three). I am using 10" jumper wires from the Arduino for power and pins 12 and 13. I am running newping with median(5). I have the HC-SR04 in a fixed position holder aiming at a 3 square inch surface that only moves in one direction directly away from the sensor (from 1" to 78"). This smooth/flat surface is accurately controlled to be square to the sensor for good signal return. With one sensor holder (this one is steel, fairly open air, and lightly holds the sensor around the two barrels) the readings are either perfect or up to 3% bad values (even after median(5) and the stationary object not very far away 15"). The other sensor holder (which is machined plastic, holds the barrels tightly, and encloses the sensor board) might work just as well or might give far more bad values. The erroneous distance values don't seem to be random. They are very similar numbers on a given day (a lot of 9" ±.3 one day, it might be around 3" another day). The "test bed" is very controlled so I don't have items causing pings one day and not the next. I bored out the tight fitting holder and hung the sensor in it with spacers to the sensor board 2 mounting holes and I didn't notice any change. I want to use this sensor and I know that this type of distance sensing isn't perfect, but I can't live with the "bad" days of the output. I can't enlarge the surface of the object being measured. I have tried changing all of the hardware with no change. I have tried USB 5v, 9vdc wall warts, and 4 x AA battery packs. I have slowed the ping rate some. I have been trying to think through the possible problems (I will list some below):Power pulsing (put a 1uF capacitor across the HC-SR04 Vcc and ground, and possibly across on the Arduino as well?).Different sensor mounting (I don't know how much direct mechanical vibration problems there are at the receive barrel from the trigger).Don't use pin13 due to the led.The Arduino and bluetooth module need to be farther away from the sensor.Use shielded cable instead of jumper wires.Interference from something in the room.Somehow pull the sensor farther back so I am not measuring the first 7" or so.Maybe change to the HY SRF05 (I kind of doubt this will help).Do you have any suggestions or do you think these sensors are just "flaky"?Thank you.
https://forum.arduino.cc/index.php?topic=106043.msg971721
CC-MAIN-2019-35
refinedweb
968
73.58
Visual Basic Developer Center | VB Team Blog | How-Do-I Videos | Power Packs | Code Samples | VB Interviews. M! I've had many questions lately on how you can query for a specific node in an XML document (or fragment) and change it's value using LINQ. (This must mean that people are really starting to use this stuff so I'm pretty excited.) This is really easy to do because you can modify the values of the selected XElements from your queries and that will change the source XML. Here's an example: Imports < Module Module1 Sub Main() Dim plants = <>Mostly Shady</LIGHT> <PRICE>$9.37</PRICE> <AVAILABILITY>030699</AVAILABILITY> </PLANT> <PLANT> <COMMON>Marsh Marigold</COMMON> <BOTANICAL>Caltha palustris</BOTANICAL> <ZONE>4</ZONE> <LIGHT>Mostly Sunny</LIGHT> <PRICE>$6.81</PRICE> <AVAILABILITY>051799</AVAILABILITY> </PLANT> </CATALOG> Dim q = From plant In plants...<PLANT> _ Where plant.<COMMON>.Value = "Columbine" _ Select plant For Each item In q q.<PRICE>.Value = "$49.99" q.<LIGHT>.Value = "Full Sun" plants.Save("plants.xml") End Sub End Module Couple things to note above, remember to import any namespaces being used in the XML otherwise your query will yield no results. And remember you can get XML IntelliSense if you import a schema (this is really easy, watch this). Of course, you can load the XML from a file (or URI) instead of using a literal and and get the same results. Dim plants = XDocument.Load("plants.xml") Dim q = From plant In plants...<PLANT> _ Where plant.<COMMON>.Value = "Columbine" _ Select plant For Each item In q q.<PRICE>.Value = "$49.99" q.<LIGHT>.Value = "Full Sun" plants.Save("plants.xml") In this example we're overwriting the source document, plants.xml, with our new values. Both examples produce this resulting XML: <>Full Sun</LIGHT> <PRICE>$49.99</PRICE> <AVAILABILITY>030699</AVAILABILITY> </PLANT> <PLANT> <COMMON>Marsh Marigold</COMMON> <BOTANICAL>Caltha palustris</BOTANICAL> <ZONE>4</ZONE> <LIGHT>Mostly Sunny</LIGHT> <PRICE>$6.81</PRICE> <AVAILABILITY>051799</AVAILABILITY> </PLANT> </CATALOG>!
http://blogs.msdn.com/bethmassi/
crawl-001
refinedweb
336
59.8
To me, by far the most interesting feature that sets NTFS apart from other great file systems like ZFS and Btrfs is the support for transactions. I really don't understand why programs don't make greater use of it. I would really like to see it used for things like installs, etc. Both have transactions, but not like TxF. The transactions in Btrfs and ZFS is system level (like snapshots) and they block all other operations while they are running. (Correct me if I'm wrong, but this was how it worked, last I heard.) That's my point. As far as I'm aware, ZFS and Btrfs transactions do block everything else, making them useless except in a few very specific scenarios. Uhm, what? Every single write operation in ZFS is a transaction, and is atomic: either the write happened and the new data is available, or the write failed and the old data is available. You never get partially written data. If something does go wrong, and there's a problem with the pool at import, you use zpool import -F <poolname> to roll back one transaction. If that still fails, you keep going, rolling back transactions until you get an importable pool. Transaction support has been built into ZFS from day one, and is one of the core principals of ZFS. Maybe I haven't been very clear. The transactions in ZFS are system level. Individual applications can't create isolated transactions on different parts of the file system. With TxF, an installer could, for example, create a transaction for the install process so that if you lost power, the install would not be half done. However, a file you saved between the start of the install and the power loss would still be there. NTFS rocks, don't let anybody fool you. Transparent compression, encryption, rich acl and a lot of other stuff I don't know about. Too bad some features are not exposed to the interface (hard/soft links for example). And only after 20 years the cracks start to appear. Throw a few hundred thousand files in a directory and it breaks down. But other than that, i have little to complain. The absolute crap Microsoft build on top of it is an insult to the original designers. We need more metadata in NTFS, but this is not the way to go. NTFS did its job, it did it well but the time for plain filesystems have passed. We need something like ZFS for the volume management and BeFS for the metadata and we are good for another 20 years. No rewrite needed Did you disable short name generation? I don't think the article mentioned this, but NTFS generates two links per file: the name you use (long name) plus an autogenerated short name for DOS applications if the name you use is not 8.3 compliant. Unfortunately the 8.3 namespace tends to congest pretty quickly, leading to painful times to insert and delete entries as NTFS searches for a free name. Turning off shortname generation dramatically improves scalability at the filesystem level. Explorer et al may still struggle, but that's a different issue. - M Turning off short filename generation on a stable production server is a bit of a no-go. But you might be right, since the files started with the same characters. I suspected improper hashing or something like that in the first place, but it was a long time ago. Listing the directory took about 15 minutes before it even started printing in a dosbox, deleting the files was a pain. Explorer struggles even with a few hundred files, which is what i meant with the crap they build on top of it. I really look forward for the day 8.3 is disabled by default and explorer is usable. Now i'm a ZFS fanboy, which has different imperfections. I admit, I view NTFS as a relatively nice and very reliable filesystem. I don't recall ever losing a file on it as a result of a problem with the filesystem itself. It beats the living hell out of FAT, which would always manage to "lose" critical system files and require copying them back over from the OS CD back in the Win9x days (though to be fair, this could have equally been caused by these OSes' tendency to crash and burn constantly, but IMO likely a combination of poor filesystem *and* operating system design...). But one thing I will never praise NTFS for: performance. Sure, NTFS can take a hell of a lot more fragging than FAT ever could and slow down less due to it, but it still fragments to hell and back in very little time of normal use and will noticeable slow down in a short amount of time. Just like its predecessor, it constantly needs defragged--once every week (two at the very most) back when I used to run Windows XP on NTFS. And no, from what I've seen of Vista/7, it's not improved; the filesystem still seems happy to scatter pieces of files all over the disk. When nice and clean (no or few excess fragments) NTFS is very snappy. It's just too bad it can't stay that way for much more than a week. Because nearly every OS supports FAT32. My guess is it makes it seem somewhat future-proof in the eyes of management. "We can change everything and that drive will still work!" I would never use NTFS in a set-top box, because most of those run some kind of Linux, and ntfs-3g is _usable_, but I avoid writing to NTFS volumes like the plague. Most of the problems I had with it were years ago, but partly because I've only had to deal with NTFS once since them (Mac user bought a sata drive from me and wanted some data from me as well, but FAT32 didn't support many of the filenames). I enjoyed the article somewhat, I like technical stuff about filesystems. What I don't understand is what public the author is trying to reach... if you are talking about using file streams or file system journalling, is it really necessary to point out that there is a button in the lower left of the Windows desktop that is called "Start"? Some comments about NTFS' problems would have been fair too. Like the fact that it is very prone to fragmentation and that it cannot handle directories with a large amount of files inside. And I don't really think Stacker was big in the last decade... he's talking about the 90s. I don't like the master file table, because it doesn't seem to be duplicated anywhere although it's possible to manually do that. The reason is that I've seen what happens when it gets corrupt, especially when the information about free and used space becomes inconsistent. This gives you the disappearing file effect, where by some of your files get accidentally replaced with newly created files because the mft had the wrong information. Usually this is fixable in the sense that you can stop the corruption and return the information to a consistent state, but no amount of fixing gets you those files back again. The mft should auto-duplicate every so often so that if the main one becomes inconsistent the fs can look to the backups and automatically bring it back into line. It's possible to manually do this, but it should be done constantly. This post seems to be confusing a lot of different issues. Firstly, the MFT doesn't track free space; the volume bitmap does. If you have two files that exist on a volume that both believe they own the same cluster, that's corruption in the volume bitmap, not the MFT. Making a file disappear requires lot of changes. It needs to clear an MFT bitmap entry, the MFT record, the index entry/entries, etc. There is some level of redundancy here: if an MFT bitmap entry is marked as available, NTFS will try to allocate it, then realize the MFT record is still in use and will abort the transaction. If I had to speculate, I'd say you're seeing the effects of NTFS selfhealing, which attempts to resolve on disk inconsistencies automatically. If it really annoys you, you might want to turn it off. Oh, and NTFS does duplicate the first four MFT records. Originally (back in Gary's time) this spanned the whole MFT, but that didn't seem like a valuable way to spend space. Most notably, there's always the issue of knowing when information is wrong - having two copies is great, but you still need to know which copy (if any) to trust. Reading both would be very expensive, so this really needs a checksum, and you start getting into substantial changes after that. - M File by file compression I think is intended for btrfs, but otherwise it is unknown in Linux. Alternative streams are common in Mac. They sound useful, but without awareness of them, they are also quite scary. I was mostly surprised by the description of hard link: When you change the links attributes, the target attribute changes, ok When you delete the link, the target is deleted.. Wait? This is not how it works in linux and posix. In posix filesystems the target is an inode and it is ref-counted, and only deleted when the last link to it disappear. Deleting a hard link doesn't delete the file. In fact you can delete the links 'target' and the so-called link will still work. I think deletion depends on the api/tool you use. If you use basic remove function, it probably only removed the link. However if you delete it from a tool that does not recognize links (say explorer), it will try to "clean up" the directory first, by removing all the contents, then rmdir it, which might keep the original directory in its place, but now empty instead of full. Nice article. btrfs and zfs now supports having multiple disks appearing as a single logical disk with data redundancy and integrity checks build in and disks can be added and removed on a "live system". Any idea of when NTFS will support this features if at all? It is my understanding that linux started btrfs with above mentioned features among others because ext FS architecture pretty much started hitting the upper limits of its feature expansion capabilities.NTFS,like ext and HFS are file systems of yesterday, zfs and btrfs are file systems of tomorrow, when will NTFS offer features they offer? Will microsoft add these features to NTFS or will they start another one to try to catch up? Last I checked (a few months ago) the ZFS file system cannot shrink volumes. The ground work was in OpenSolaris but not anywhere near production ready. So as long as that hasn't changed and you didn't mean a concat volume then you are correct about ZFS. Volumes (aka zvols) can be grown, shrunk, added, removed as needed. Volume size is just a set of properties (reservation, quota). I believe you mean that a storage pool (aka zpool, or just pool) cannot be shrunk, in that you cannot remove root vdevs. This is true. You can remove cache devices (aka L2ARC) and you can remove log devices (aka slogs) and you can remove spare devices. But you cannot, currently, remove (or alter) root vdevs (bare device, mirror, raidz). Someday, when the legendary "block-pointer rewrite" feature is completed, it will be possible to remove root vdevs; along with migrating between vdev types (mirror -> raidz; raidz1 -> raidz2), and with expanding raidz vdevs (4-drive raidz1 -> 5-drive raidz1).. Shadow copy was actually first released with Windows XP. The version that was included in Windows XP does not use NTFS for doing this. If I remember correctly, it just keeps some backup files and logfiles (so it can keep changes while a backup is running). So it is not 'compatible' and the API is different. __ I think it would have been a good idea to explain Juntion points __ Just a quick comment about File screening, this is done by extension, not filetype. While Microsoft/Windows might be confused about the difference I would think OSNews would know the difference. __ I wouldn't call NTFS advanced, though it has many features. I think most poeple would consider something like ZFS advanced. __ I always felt speed was the problem of NTFS, I think that is why Microsoft wanted to replace it with winfs and that is why SQL-Server, Exchange and some other programs don't use the normal file-API. __ Don't get me wrong, I applaud the effort. :-) Some comments on your comments: Re: Shadow Copy, Windows XP NTFS is the same as Windows Server 2003 NTFS. My impression is that junction points are mostly deprecated in favor of links. Under Windows, extensions pretty much equal file types. While I would certainly agree that ZFS is an advanced file system, I don't think that you can argue that NTFS is not an advanced file system :-) I would also add that while ZFS is an excellent server file system, you wouldn't necessarily want it on your laptop. And yes, databases like SQL Server and Oracle circumvent standard file systems for performance reasons. And yes, databases like SQL Server and Oracle circumvent standard file systems for performance reasons. I believe it is more about structure than performance. The file system is hierarchic whereas the Oracle and SQL Server are relational. They still rely on the filesystem but they store the tables and the records in one big file usually mapped to a tablespace. They can't map the tables and the records directly to the filesystem because they just are not hierarchic, not to mention the space wasted by the filesystem overhead. Interestingly, Oracle 11g implements a file system on top of its database: DBFS. I dont agree with you. The other day I screwed my Solaris 11 Express installation. I was toying with Zones (virtual machines) as a root, and by mistake typed the root command in the real computer. I just rebooted and chose an earlier snapshot in GRUB and that was it. I deleted the old snapshot which was screwed, and continued to work. What happens if you screw your Linux install? Or Windows install? Then you are screwed. With ZFS, you just reboot into an earlier snapshot, which takes one minute. Yes, you certainly want ZFS on your desktop - lest you want to reinstall and reconfig, etc for hours. And by the way, ZFS protects your data. Which no other filesystem does good enough (according to researchers). "Yes, you certainly want ZFS on your desktop"? If the "inexpensive" laptop has 2 GB or more of RAM, then you can get away with using ZFS without worrying too much about manual tuning, so long as the OS supports auto-tuning of ZFS memory settings (FreeBSD and Solaris do, no idea about Linux). However, it's not the cost of the laptop that matters, it's the integration of the ZFS features with the OS. Currently, the only real integration is done in Solaris where GNOME (via Nautilus) provides access to the automatic snapshots feature via TimeSlider, and where system updates create bootable snapshots (Boot Environments), and stuff like that. Until non-Solaris systems integrate ZFS features into the OS (especially the GUI layers), you probably won't be able to get "the unwashed masses" to use ZFS. Edited 2010-12-01 19:02 UTC I have used ZFS on OpenSolaris on a 1GB RAM, Pentium4@2.4GHz. It worked, but not fast. I got something 30MB/sec. That is because ZFS is 128 bit, and P4 is 32 bit. If you use 64bit cpu, you get full speed. Hence, you dont need 2GB RAM. Regarding if ZFS is suitable for the average user. In my opinion: yes. Because ZFS is VERY easy to use. Much easier than, for instance NTFS. It is also far flexible.. I don't think this is true. If you run ZFS on a 64-bit CPU, you get access to some 64-bit program counter registers, but the system bus, buffer size, etc is still the same.. That's good to know. Maybe some day we will see it in consumer devices. Although I don't see average consumers creating RAIDs :-) I don't think this is true. If you run ZFS on a 64-bit CPU, you get access to some 64-bit program counter registers, but the system bus, buffer size, etc is still the same. " What is not true? That ZFS needs 64 bit cpu to reach full speed? Well, everybody says so. And I think it is also stated in the ZFS guides. Many people (including me) reports low speed with 32 bit cpu. Many people (including me) reports much faster speed with 64bit cpu. For those who don't know, I spent most of the last five years working on NTFS. This article is a good overview of this and other related technologies, but I thought I just just add my nits for the record. Max FS Size NTFS on disk allows for 2^63 cluster volumes, and files of up to 2^63 bytes. The current implementation is limited to 2^32 cluster volumes, which at default cluster size comes to 16Tb, although can go to 256Tb with a larger cluster size. The real point here is the 2Tb limit referenced in the article is a limit associated with MBR partitions, not NTFS. File system files One key omission here is the USN journal. It's a nice feature that has existed since Windows 2000 and does not have a direct equivalent on other platforms. Then again, it might warrant an article all on its own. File compression The on-disk representation of NTFS compression requires a lot of synchronization and reallocation, which leads to fragmented files that are very slow to access. This feature should only be used when space is more important than speed (which is becoming increasingly rare.) Alternate data streams ADSes do not have unique cluster sizes (which is an attribute of the volume); nor independent file type associations. In Windows, file associations are extension based, and the file name is shared between all streams. Again, in another article it might be valuable to consider different approaches OSes have taken to file type associations; I still really like OS/2's EA approach. Hard links, soft links and junction points Symlinks do not replace junction points; mklink allows creation of both. These have different properties with respect to security and how they are resolved over networks. Note that the \Documents and Settings heirarchy in Vista is comprised of junctions, despite the existence of symlinks. Advanced Format Drives Vista's support for these drives was a good first step, but not complete. If you use one of these and have Win7, please consider using either Service Pack 1 prereleases or the patch located at . Transactional NTFS Back when Vista was under development, we had Beta releases that allowed CMD scripts to start transactions, launch processes, and commit from a script. Alas, it was not to be. Edit: Versioning The NTFS version was 3.0 in Windows 2000, and 3.1 ever since. The version of the NTFS on disk format has not changed since XP. New features have been added in a purposely compatible way, so a Win7 volume should be usable in Windows 2000 and vice-versa. - M Edited 2010-11-30 01:31 UTC The on-disk representation of NTFS compression requires a lot of synchronization and reallocation, which leads to fragmented files that are very slow to access. This feature should only be used when space is more important than speed (which is becoming increasingly rare.) The other instance I can think of, where compression can be beneficial, is to minimize the number of writes to the underlying storage medium. In the old days of sub-200MHz CPU's and non-DMA drive controllers, the time saved on disk I/O was a win over the extra CPU work of compression and decompression. Today, the same might be useful for increasing flash longevity. Even with wear leveling, flash can take only so many writes. (Then again, one must question the wisdom of using any journaling FS on flash...) It really depends on the meaning of "I/O". In terms of bytes transferred, compression should be a win (assuming compression does anything at all.) The issue with NTFS (or perhaps, filesystem level) compression is that it must support jumping into the middle of a compressed stream and changing a few bytes without rewriting the whole file. So NTFS breaks the file up into pieces. The implication is that when a single large application read or write occurs, the filesystem must break this up into several smaller reads or writes, so the number of operations being sent to the device increase. Depending on the device and workload, this will have different effects. It may be true that flash will handle this situation better than a spinning disk, both for reads (which don't have a seek penalty) or writes (which will be serialized anyway.) But more IOs increases the load on the host when compared to a single DMA operation. Although flash devices typically serialize writes, this alone is insufficient to provide the guarantees that filesystems need. At a minimum we'd need to identify some form of 'transaction' so that if we're halfway through creating a file we can back up to a consistent state. And then the device needs to ensure it still has the 'old' data lying around somewhere until the transaction gets committed, etc. There's definitely scope for efficiency gains here, but we're not as close to converging on one "consistency manager" as many people seem to think. Edited 2010-11-30 20:51 UTC The bigger problem with journaling on flash, is that so many FS operations need two writes: one to the journal, and then one to commit. Not good for flash longevity. In fact, early flash storage without wear-leveling got destroyed fairly quickly by journaling, when constant writing to the journal wore out the underlying flash cells in a matter of days. "WinFS was likely sacrificed to get a ship date for Vista." Perhaps, but it was cancelled in 2006 and has yet to appear so I assume there must have been more to it then that. Pity, as I was rather looking forward to it at the time. Seemingly, the more time passes and the greater the data even individuals have the more useful it would've been. Edited 2010-11-30 02:55 UTC It also didn't have very good performance. Longhorn in general was bad, but with winFS ... yikes, it was scary slow. At the time it was blamed on it being a debug build, then it was just dropped. Its basically been in development since the early 90s ( as a part of cairo). I think its just a bad idea for an implementation. My 2 cents is that a better more specific, transparent database for specific filetypes is a better idea. Take a look at your typical Computer. Count all of the files on the Hard disks. How many of them have been created by the user, and how many are just for the OS and applications? If you could somehow apply indexing/database storage on the user created files, you'd have something scary fast and very useful. You can either buid some crazy intelligence into the FS, so every application has it with no new build ( Very difficult, IMHO) Or just create a new open file function in the OS, that designates it to be a "user generated file" and get all app developers to use that ( easier implementation, not going to work for a while...) I was really wondering if you meant it woudl be transparent to the programmer or not. I don't think it would be trivial to have it Identify user created files in the api. In order for it to be transparent the function calls to save a config file ( non user created file) and a document ( user created file) woudl have to be the same while the api would have to figure out with some sort of algorithm which was created by the user and which was not. As a programmer, some of the documents I create are indistinguishable from config files, because they are config files as well as documents I created. I'd want those to be all metadated up, but not any that were tweaked for me by an existing application I didn't write. See the complexity of that? It would be easier to simply have a different api call for the two file writes, one with meta data and one with out, but then you have to get third party developer buy in. WinFS was sacrificed because it's a good idea that just cannot be done practically. Be tried to do the same thing with its early releases and found that they couldn't get it together, either, which prompted the rush to build BeFS before 1.0 shipped. It's unquestionably a hard problem and there is some question as to whether or not it can be solved in a way which is reliable and performant. You will probably not see a database FS any better than BeFS any time soon. That's quite a heavy feature list ! Now I understand better why it took so much time before NTFS was properly supported on Linux In my opinion, a FS should focus on ensuring high performance and reliability, and the rest should be left to higher-level OS components as they are OS-specific features which all people who implement NTFS do not necessarily want to support. But well... Windows 95 OSR2 was the first consumer OS to support FAT32 (as opposed to Windows 95 vanilla as they were different products if essentially the same run time executive) OSR2 was OEM only and was also the first Windows version to support USB. Good times. Edited 2010-11-30 08:53 UTC To be pedantic, it was Win95b that first supported USB. Win95a did not support USB. And Win95c was the best one of the bunch (aka OSR2.1 or something like that). "OSR2" was an umbrella term that covered Win95a through Win95c. Supposedly, there was also a Win95d, but I never saw it in the wild. Gotta love how MS names things, eh?. NTFS is not safe from a data integrity view. It might corrupt your data. The worst case of corruption is when the data is corrupted silently, i.e. the hardware nor the software never notices that data has been corrupted. Thus, you get no warning at all. You think your data is safe, but it has been silently altered on disk:... Using hardware raid is no better. It does not give you data protection. But ZFS gives you data protection. Read more on this, here: It is technically good but it is wasted by closeness, patents and copyrights. Its value is greatly diminished by the fact that its structure is not published. You don't know if your disk will be readable in 10 years and you can't trust implementations based on reverse engineering. That is why FAT32 will remain the de-facto standard for removable drives. FAT32 is also closed but it is far simpler and reverse engineering is more reliable. NTFS could have been much more useful but it has been wasted for very dumb business reasons. That is a shame. Considering that it has been around for 17 years, and given Microsoft's long track record on providing backwards-compatibility, I don't think NTFS support will come anywhere near disappearing in the next 10 years. Whether or not that's a good thing is a different argument. Every time I read about what NTFS can do I wonder why MS always tries to cripple it. It is limited by the software on top. Apparently it could have: - Longer than 255 characters(I have had to shorten a lot of directories and filenames) - Automatic backup while the system is running - File deduplication with hardlinks or something similar - Smarter algorithms to avoid fragmentation - Roll back the system to a clean install(without losing userdata) - Grown the only partition on the system by just installing a new harddrive and linking it to it - A tagging system built in(for an extra organization method on top of the filesystem) I still find it hard to believe that MS could have solved 99% of the problems people have with Windows by using functionality already present in the filesystem... Yes. If you insist on having case insensitivity for e.g. file names entered by user, do it in a library - open_file_case_insensitive("/TmP/Hello.TXt"). Don't break the whole operating system down to the very core for it. While windows kernel probably is becoming ok these days, it's still crippled by various user-visible warts like: - drive letters - backslash recommended as path separator - CR LF - inability to delete/move files that are in use - case insensitivity Any pretense of elegance elsewhere is stained by these issues. Unix has warts too (terminal handling, whatever), but people rarely see those while the windows ones you hit several times a day. Excuse me, but that does not sound like hard links as they have been known in Unix-land. What you have just said is that changes to the hard link file change the target, which is true since they are the same file, but it is certainly not true on Unix filesystems that deleting a hard link deletes the file its linked to. Having just tested it on NTFS confirms my suspicions: NTFS doesn't do it this way either. Deleting all links to a file when you delete any one link would be crazy behavior. NTFS hard links work like Unix hard links. Apart from inaccuracies like this I found the article usefully informative. I would like to see a comparison by someone who knows filesystems better than I do between NTFS and NSS, which was produces somewhat later, to contrast the different feature sets. I know that NTFS has relatively weak performance characteristics, possibly due to its complexity, and I know that NSS is pretty good in that area while having AFAIK an equivalent feature set. Edited 2010-11-30 12:35 UTC I was looking at the EFS problems and most of these (none?) strike me as problems at all, but one of them is flat out incorrect: # If your PC is not on a domain and someone gets physical access to it, it's very simple to reset your Windows password and log in. This is true, however, resetting an account password from outside of the account (as opposed to logging in and changing the password) will invalidate the EFS keys bound to that account. The password for the user account is used to decrypt the relevant EFS keys, and thus, by changing it from outside of the account access to the EFS keys for that account can't be gained and will be permanently lost once the password is forcibly reset. Windows will infact warn you of this when you try to do so, through, e.g. Local Users & Groups: "Resetting this password might cause irreversible loss of information for this user account. For security reasons, Windows protects certain information by making it impossible to access if the user's password is reset. This data loss will occur the next time the user logs off." This makes sense, as the EFS keys that are being held in their decrypted form in memory will cease to exist on log-off and their encrypted equivalents on disk will no longer be possible to decrypt. In short, you'd have to bruteforce the password to guarantee access to EFS encrypted user data, not reset. Disclaimer: Windows 2000 has some flaws in the EFS implementation and default settings that make some of the above less true. XP and newer are not vulnerable; Vista and newer even less so. Edited 2010-12-02 12:36 UTC
http://www.osnews.com/comments/24076
CC-MAIN-2014-15
refinedweb
5,448
70.43
Remote Debugging The debugging of an external process from within Eclipse is supported through remote debugging. The process can be running on the same machine as the debugger or a separate machine on the network. Unfortunately, the VMs of various vendors do not all turn on their debug-listening capabilities in the same way. The following example uses the standard Java VM and its documented command-line options. The first step is to ensure that the compiler has debugging turned on. Open the Eclipse Preferences dialog and go to the Java compiler page (Window, Preferences, Java, Compiler). Click the Compliance and Classfiles tab and look at the settings for Classfile Generation. For this example, make sure all the boxes are checked, although in general, Preserve unused local variables can be unchecked (see Figure 3.6). Clicking OK will force a rebuild of the current projects. In the Calculator project, create a new class named CalculatorInput. This class will read a string of digits from the command line, add them up, and print the result of the addition. All the generated comments have been removed: public class CalculatorInput { private BufferedReader _in; private SimpleCalculator _calculator; public CalculatorInput() { InputStreamReader reader = new InputStreamReader(System.in); _in = new BufferedReader(reader); _calculator = new SimpleCalculator(); } public static void main(String[] args) { CalculatorInput app = new CalculatorInput(); try { app.start(); } catch (IOException e) { System.out.println("Exception found: " + e.getMessage()); } } public void start() throws IOException { String calcStr = null; System.out.println( "Enter a space-separated list of numbers to add (q to exit):"); calcStr = _in.readLine(); int [] value = null; int result; while(calcStr.equals("q") == false) { result = 0; value = parseValues(calcStr); for (int i = 0; i < value.length; i++) { result = _calculator.add(value[i], result); } System.out.println("Result: " + result); calcStr = _in.readLine(); } } private int[] parseValues(String calcStr) { int [] result = null; Vector v = new Vector(); StringTokenizer tokenizer = new StringTokenizer(calcStr); while (tokenizer.hasMoreTokens()) { String strVal = (String) tokenizer.nextToken(); v.add(strVal); } result = new int[v.size()]; for (int i = 0; i < result.length; i++) { result[i] = Integer.parseInt((String) v.get(i)); } return result; } } Figure 3.6 The Preferences dialog with all classfile generation options checked. Do not worry about the missing package imports. When you have typed the preceding code into Eclipse, you can press Ctrl+Shift+O and all the missing imports will be added to the file. Save CalculatorInput. Export the Calculator project by right-clicking the project name and selecting Export from the pop-up menu. When the Export dialog opens, select JAR file as the export destination. Click Next. In the list to the right of the project, uncheck .classpath, .project, and calculator.jpage. Exporting them will not cause any damage, but they are not needed. In the Select Export Destination field, enter c:\calc.jar or any safe location where you can find the file later, but still name the JAR file calc.jar. Click Next. The JAR Packaging Options page can be left alone, so click Next. In the JAR Manifest Specification page, click the Browse button, located toward the bottom of the page, and select CalculatorInput from the Select Main Class dialog. Click OK. The new class, eclipse.kickstart.example. CalculatorInput, is now assumed to be the class to be run when you run the JAR file from the command line. Click Finish to complete the export process. Open a command-line window and change directory to wherever it is you saved calc.jar. If you are running on Windows, the easiest location to run this from is the C drive, which is why you entered c:\calc.jar as the target export directory. Make sure you can run Java from the command line. If not, update your path variable to include Java's bin directory so that you can run CalculatorInput from the command line. Enter the following on the command line: C:\> java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y -jar calc.jar All this must be on one line. Press Enter, and the program prompts you to enter a string of space-separated numbers, or you can enter the letter q to exit. If the program does not prompt you, check that you have entered everything as listed here. The JVM -X Options If you are using the standard Javasoft-supplied JVM, here is a caveat on the preceding command-line listing: The -X command-line option for the JVM defines options that may go away someday. The two options have been around for a few years, but there are no guarantees they will stay that way. Always refer to your vendor documentation to discover what options are available to turn on remote debugging. The command-line options are as follows: -XdebugNotifies the VM that an external process may connect to it. -Xrunjdwp:Contains the list of comma-separated configurations needed by the VM to allow an external process to connect to it: transport=dt_socketThe VM can expect the external process to connect via a socket. address=8000The external process will connect using this port. suspend=nThe VM should not suspend the program while it waits for the external program to attach. server=yThe VM should behave like a server. Enter the string 0 1 and press Enter. The program will display Result: 1. Let's attach the Eclipse debugger to this process. To attach the Eclipse debugger to an external Java program, it has to be told which machine the external program is running on and what port it can use to communicate with it. This information is entered through the Launcher dialog. Select from the main menu Run, Debug to open the Launcher dialog specific to debugging. Select Remote Java Application as the configuration type and click New. This configuration information will be used by the debugger to connect to the external program. Enter the following configuration information: Name: Remote Calculator Project: Calculator Connection Type: Standard (Socket Attach) Connection Properties: Host: localhost Connection Properties: Port: 8000 Click Debug to start up the debugger and have it attach to CalculatorInput. The Debug perspective will open and the Debug view will display the Calculator as running in a Java HotSpot Client VM. Right-click the third line of the stack frame (Thread [main](Running)) and select Suspend from the pop-up menu. The external VM will suspend the named thread "main" and the debugger displays what the current stack looks like (see Figure 3.7). The second-to-last line of the stack is the call from CalculatorInput.start(). Select this line and the CalculatorInput file will open in the editor at the proper location. Figure 3.7 The debugger with the Debug view showing the stack trace for the remote CalculatorInput program. The editor is open to the line at which the process is suspended. The Variables view displays the this and calcStr references as set in the external process. Set a breakpoint at the first line inside the while loop and press F8 to resume the thread. Bring the command-line window forward, enter the string "2 2" and press Enter. The debugger will suspend execution of CalculatorInput and display the line within the code where the breakpoint was hit. The Variables view displays three variables: this, calcStr, and value, which was created after the call to in.readLine(). From within the Variables view, double-click calcStr and change its value from "2 2" to "5 5". When the Set Variable Value dialog opens, do not enter quotes around the values. Click OK and then press F8 to resume execution. The result of the addition of "2 2" is now 10. From the command line window, type q to end the CalculatorInput session. Once the debugger has connected to the external process, you can use many of the standard features of the debugger, but remember that you cannot do things like hot-swap code. If you change the code in the debugger while you are debugging, the debugger will flag the code as out of sync with the running code and will not allow you to use the file for the debugging session.
http://www.informit.com/articles/article.aspx?p=336709&seqNum=4&rll=1
CC-MAIN-2016-30
refinedweb
1,350
56.96
Packages not avaible in Pycharm Follow Bjerrum Created April 07, 2013 19:05 I use external packages as networkx, pyplot, gurobi and it works fine in a console, but i can not get it to work in Pycharm. I have tried to setup patches under "Python Interpreters", but without success. Any hint? What are your Python paths? (Preferences | Project Interpreter| Python Interpreters | Paths). Where these modules are located? Run from a console: prettyPrint(); I have the same problem with Gurobi. Everything works well in terminal when I execute "python <file name.py>" but it pycharm I get this error: /usr/bin/python /home/amir/PycharmProjects/test2/test2.py Traceback (most recent call last): File "/home/amir/PycharmProjects/test2/test2.py", line 97, in <module> from gurobipy import * File "/usr/local/lib/python2.7/dist-packages/gurobipy/__init__.py", line 1, in <module> :-)
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206597675-Packages-not-avaible-in-Pycharm?page=1
CC-MAIN-2019-30
refinedweb
142
60.51
On Sun, 2009-08-02 at 14:38 +0200, Reimar D?ffinger wrote: > On Sun, Aug 02, 2009 at 09:13:33PM +1000, stev391 at exemail.com.au wrote: > > + /* Read the Sequence Description to determine if start of RLE data or Appended to previous RLE */ > > + sequence_desc = bytestream_get_byte(&buf); > > I didn't even know this function existed, but since buf is > uint8_t * I think just using the usual "*buf++" would be preferable... > This would then reduce readability and increase complexity using the mix of commands, none changed. > > + av_freep(&ctx->picture->bitmap); > > + > > + ctx->picture->bitmap = av_malloc(width * height * sizeof(uint8_t)); > > sizeof(uint8_t) is useless. Agreed >)? > > > + while (buf < rle_bitmap_end && line_count < height) { > > + block = bytestream_get_byte(&buf); > > + > > + if (block == 0x00) { > > + block = bytestream_get_byte(&buf); > > + flags = block & 0xC0; > > I'd consider using *buf, *buf++ or similarly directly See above > > > + switch (flags) { > > + case 0x00: > > + run = block & 0x3F; > > + if (run > 0) > > + colour = 0; > > + break; > > + case 0xC0: > > + run = (block & 0x3F) << 8 | bytestream_get_byte(&buf); > > + colour = bytestream_get_byte(&buf); > > + break; > > + case 0x80: > > + run = block & 0x3F; > > + colour = bytestream_get_byte(&buf); > > + break; > > + case 0x40: > > + run = (block & 0x3F) << 8 | bytestream_get_byte(&buf); > > + colour = 0; > > + break; > > + } > > Note: we use US English, so it should be color for consistency with other code. Sorry I'm Australian, fixed. > > flags = *buf; > run = *buf++ & 0x3f; > if (flags & 0x40) > run = run << 8 + *buf++; > color = flags & 0x80 ? *buf++ : 0; Hmm, very efficient, why didn't I think of that... Only one minor detail is that the flags and the initial run value come from the one byte. Implemented using bytestream_get_byte to increase readability. Also fixed a check slightly further down in regards to ensuring the buffer is not exceeded (previously I was not writing the last run of colour, which just happened to be '0' colour anyway). > > > + /* Store colour in palette */ > > + if (colour_id < 255) > > Strange, 255 is not a valid palette index? > IMO this warrants an extra comment I was off by one. > > > + /* Skip 1 bytes of unknown, frame rate? */ > > + buf += 1; > > buf++; Fixed > > > + x = 0; y =0; > > Missing space after =, also could be > x = y = 0; Fixed > > > +#ifdef DEBUG_SAVE_IMAGES > > +#undef fprintf > > +#undef perror > > +#undef exit > > +static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h, > > + uint32_t *rgba_palette) > > +{ > > + int x, y, v; > > + FILE *f; > > + > > + f = fopen(filename, "w"); > > + if (!f) { > > + perror(filename); > > + exit(1); > > + } > > + fprintf(f, "P6\n" > > + "%d %d\n" > > + "%d\n", > > + w, h, 255); > > + for (y = 0; y < h; y++) { > > + for (x = 0; x < w; x++) { > > + v = rgba_palette[bitmap[y * w + x]]; > > + putc((v >> 16) & 0xff, f); > > + putc((v >> 8) & 0xff, f); > > + putc((v >> 0) & 0xff, f); > > + } > > + } > > + fclose(f); > > +} > > +#endif > > That obviouslyy should go for the final version, if it is not already possible ffmpeg > might be extended to allow for this. Removed (A similar function is in the DVD and DVB subtitles file, that is why I left it there). > > > + sub->rects[0]->pict.data[1] = av_mallocz(sub->rects[0]->nb_colors * sizeof(uint32_t)); > > + > > + memcpy(sub->rects[0]->pict.data[1], ctx->clut, sub->rects[0]->nb_colors * sizeof(uint32_t)); > > Initializing to 0 and then fully memcpying it over seems like overkill, av_malloc instead > of av_mallocz should do it I think. Fixed > Well, except that pict.data[1] I think always needs to have the size for 256 palette entries, > not just nb_colors... nb_colors is 256 (set on previous lines directly above), in future I was thinking of limiting the size, but as this will introduce slightly more complicated checking in the palette parsing I thought I would commit the working code first. (I subscribe to the commit often ideology) > > > + if (!(segment_type == DISPLAY_SEGMENT) && (buf + segment_length > buf_end)) > > Uh, !(a == b) should be a != b... also some useless (). > Also the check is wrong, > buf + segment_length can overflow, > segment_length > buf_end - buf > is the correct way that avoids an overflow. Fixed > _______________________________________________ Michael, Sorry I had a brain fade, I thought it was '/' not '%' when I replied to your comments. Updated patch attached. -------------- next part -------------- A non-text attachment was scrubbed... Name: bluray_subtitles_ffmpeg_19571_v7.diff Type: text/x-patch Size: 15513 bytes Desc: not available URL: <>
http://ffmpeg.org/pipermail/ffmpeg-devel/2009-August/060653.html
CC-MAIN-2015-06
refinedweb
658
61.26
I am completly lost with arrays. I have scoured my book and the exaamples it gives are way to simple. I can wrerite them like those in the books, but I cannot seem to get the real problem to work. Also I am doing ifstream and ofstream so I cannot really see what is happening. I printed to screen once and it was just a bunch of garbage. Here is the problem: I have to take input from the file PianoREV.data and output it to Report.out. I need to setup parallel partially filled arrays for the contestant id's, student level, composision difficulty rating, num judges and overall averages. I need two dimensional arrays for the judge ids judges scores and weighted scores. Then a print report fucntion comes and prints it all. I have not attempted to write this as i cannot get the arrays to work to begin with. Here is an example of the PianoREV. 6010 1 1.3 23 7.0 25 8.5 34 7.0 12 7.5 -1 6012 1 1.2 23 7.5 34 7.0 45 7.0 50 7.5 -1 The first number is the player id. the second the proficiency level, the third is the weight factor, followed by judge and then score. I had a lot of help with psuedo code on the first assignment based on this task and would depply appreciate some more. MY teacher is really not helping any of us. Half the class has dropped and the other half is failing. Anyways here is what i have so far. Am I even going in the right direction? #include <iostream> #include <fstream> #include <cstdlib> using namespace std; const int MAXMEMBERS = 25; int ReadScores (ifstream& fin, int pianoPlayer[MAXMEMBERS], double score[MAXMEMBERS]); int pianoPlayer[MAXMEMBERS]; double score[MAXMEMBERS]; double weightFactor[MAXMEMBERS]; int profLevel[MAXMEMBERS]; const int MAXJUDGES = 7; int main() { ifstream fin; ofstream fout; fin.open("PianoREV.data"); if (fin.fail()) { cout << "Error: Input File"; exit (1); } fout.open("Report.out"); if (fout.fail()) { cout << "Error: Output File"; exit (1); } ReadScores (fin, pianoPlayer, score); fin.close(); fout.close(); } int ReadScores (ifstream& fin, int pianoPlayer[MAXMEMBERS], double score[MAXMEMBERS]) { int countPlayers = 0; while (countPlayers < MAXMEMBERS && (fin >> pianoPlayer[MAXMEMBERS])) { int i = 0; int judgeNumber[i]; fin >> profLevel[countPlayers]; fin >> weightFactor[countPlayers]; while (judgeNumber[i] != -1) { for(i = 0; i<MAXJUDGES;i++) { fin >> judgeNumber[i]; fin >> score[i]; fin >> judgeNumber[i]; } } } return countPlayers; }
https://www.daniweb.com/programming/software-development/threads/41886/help-with-parrallel-arrays
CC-MAIN-2017-17
refinedweb
408
69.58
Contour Plot not working with pseudo-piecewise function Hi, I'm fairly new to Sage and don't know if this is a bug or just my own limited understanding. I want to plot a function 'f(g1, g2)' but only in some relevant area of the plot. All other points should display/evaluate to zero. This should work fine in Octave or numpy but Sage for some reason gives me an error-message which I fail to understand. Function assignment like so: def f(g1, g2): if g1*g2 > 0.0: if abs(g2) < 1/abs(g1): return sqrt(0.5*((1+g1*g2)*abs(g1+g2))/(sqrt((1.0-g1*g2)^3)*g1*g2)) else: return 0 Then the Plot: var('g1 g2') contour_plot(f(g1,g2), (g1,-4,4), (g2,-4,4),plot_points=500, cmap='afmhot_r', colorbar=True, contours=srange(1,6,0.5)) and at last the error-message: ValueError: zero-size array to ufunc.reduce without identity Strangely, if I assign a single number to 'contours' (or leave it out to get the default value) the error-message does not show but instead I get an empty/white plot. If I do not use a conditional/if-statement in my function-assignment the contour-plot shows just fine (except that it didn't do what I wanted). Does anyone know how to fix this or why it doesn't work or at least why I'm being silly for even trying it that way? Thanks in advance
https://ask.sagemath.org/question/8370/contour-plot-not-working-with-pseudo-piecewise-function/
CC-MAIN-2020-45
refinedweb
252
63.39
C programming interview questions are a part of most technical rounds conducted by employers. The main goal of questioning a candidate on C programming is to check his/her knowledge about programming and core concepts of the C language. In this article, you will find a mix of C programming interview questions designed specially to give you a foundation and build on it. And before going ahead, if you want to know more about C programming, check out what is c programming now? Basic C Programming Interview Questions Let’s start with some basic interview questions on c: 1. What do you understand by calloc()? calloc() is a dynamic memory allocation function that loads all the assigned memory locations with 0 value. 2. What happens when a header file is included with-in double quotes ““? When a header file is included in double-quotes, the particular header file is first searched in the compiler’s current working directory. If not found, then the built-in include path is also searched. 3. Define <stdio.h>. It is a header file in C that contains prototypes and definitions of commands such as scanf and printf.[2] [MOU3] 4. One of the most common c interview questions is to define theWhat is the use of static functions.? When we want to restrict access to functions, we need to make them static. By making functions static, we can reuse the same function name in other files. 5. Name the four categories in which data types in the C programming language are divided in. Basic data types - Arithmetic data types, further divided into integer and floating-point types Derived datatypes -Arithmetic data types that define variables and assign discrete integer values only Void data types - no value is available Enumerated data types -Array types, pointer types, function, structure and union types 6. What is the function of s++ and ++s? s++ is a single machine instruction used to increment the value of s by 1. (Post increment). ++s is used to carry out pre-increment. 7. What is the use of the ‘==’ symbol? The ‘==’ symbol or “equivalent to” or “equal to” symbol is a relational operator, i.e., it is used to compare two values or variables. 8. What is the output of the following code snippet? #include <stdio.h> void local_static() { static int a; printf("%d ", a); a= a + 1; } int main() { local_static(); local_static(); return 0; } 0 1 9. Mention some of the features of the C programming language. Some of the feature are: Middle-Level Language - Combined form of both high level language and assembly language Pointers - Supports pointers Extensible - Easy to add features to already written program Recursion - Supports recursion making programs faster Structured Language - It is a procedural and general purpose language. 10. Name a ternary operator in the C programming language. The conditional operator (?:) Intermediate C Programming Interview Questions Here are some frequently asked intermediate interview questions on C programming! 1. Why is int known as a reserved word? As int is a part of standard C language library, and it is not possible to use it for any other activity except its intended functionality, it is known as a reserved word. 2. This is one of the most commonly asked C programming interview questions. What will this code snippet return? void display(unsigned int n) { if(n > 0) { display(n-1); printf("%d ", n); } } Prints number from 1 to n. 3. Another frequent c interview question is what is meant by Call by reference? When a variable’s value is sent as a parameter to a function, it is known as call by reference. The process can alter the value of the variable within the function. 4. What information is given to the compiler while declaring a prototype function? The following information is given while declaring a prototype function: - Name of the function - Parameters list of the function - Return type of the function.[6] 5. Why are objects declared as volatile are omitted from optimization? This is because, at any time, the values of the objects can be changed by code outside the scope of the current code. 6. Give the equivalent FOR LOOP format of the following: a=0; while (a<=10) { printf ("%d\n", a * a); a++; } for (a=0; a<=10; a++) printf ("%d\n", a * a); 7. What is a modifier in the C programming language? Name the five available modifiers. It is used as a prefix to primary data type to indicate the storage space allocation’s modification to a variable. The available modifiers are: - short - long - long long - signed - unsigned 8. A pointer *a points to a variable v. What can ‘v’ contain? Pointers is a concept available in C and C++. The variable ‘v’ might contain the address of another memory or a value. 9. What three parameters fseek() function require to work after the file is opened by the fopen() function? The number of bytes to search, the point of origin of the file, and a file pointer to the file. 10. Name a type of entry controlled and exit controlled loop in C programming. Entry controlled loop- For loop (The condition is checked at the beginning) Exit Controlled loop- do-while loop.[7] (The condition is checked in the end, i.e. loop runs at least once) Advanced C Programming Interview Questions In the next section, we will go through some of the advanced interview questions on C programming: 1. Give the output of the following program: #include <stdio.h> int main(void) { int arr[] = {20,40}; int *a = arr; *a++; printf("arr[0] = %d, arr[1] = %d, *a = %d", arr[0], arr[1], *a); return 0; } arr[0] = 20, arr[1] = 40, *p = 40 2. One of the frequently asked c interview questions could be to explain Canif you can we free a block of memory that has been allocated previously? If yes, how? A block of memory previously allocated can be freed by using free(). The memory can also be released if the pointer holding that memory address is: realloc(ptr,0). 3. How to declare a variable as a pointer to a function that takes a single character-pointer argument and returns a character? char (*a) (char*); 4. What is the stack area? The stack area is used to store arguments and local variables of a method. It stays in memory until the particular method is not terminated. 5. What is the function of the following statement? sscanf(str, “%d”, &i); To convert a string value to an integer value. 6. Will the value of ‘a’ and ‘b’ be identical or different? Why? float num = 1.0; int a = (int) num; int b = * (int *) # The variable stores a value of num that has been first cast to an integer pointer and then dereferenced. 7. What are huge pointers? Huge pointers are 32-bit pointers that can be accessed outside the segment, and the segment part can be modified, unlike far pointers. 8. What will be the output of the following? #include<stdio.h> main() { char *a = "abc"; a[2] = 'd'; printf("%c", *a); } The program will crash as the pointer points to a constant string, and the program is trying to change its values. 9. What is a union? A union is a data type used to store different types of data at the exact memory location. Only one member of a union is helpful at any given time. 10. How is import in Java different from #include in C? Import is a keyword, but #include is a statement processed by pre-processor software. #include increases the size of the code. Here’s The Next Step Go through your self-made notes while preparing for the interview. As a fresher, you aren’t expected to answer complex questions but answer what you know with confidence. One of the essential uses of C programming is full-stack development. If that’s a position you aim to crack in your following interview, check out this comprehensively curated course by Simplilearn and kickstart your web development career now! If you are looking for a more comprehensive certification course that covers the top programming languages and skills needed to become a Full Stack developer today, Simpliearn’s Post Graduate Program in Full Stack Web Development in collaboration with Caltech CTME should be next on your list. This global online bootcamp offers work-ready training in over 30 in-demand skills and tools. You also get to immediately practice what you learn with 20 lesson-end, 5 phase-end and a Capstone project in 4 domains. This needs to be the next goal in your learning and career journey.
https://www.simplilearn.com/tutorials/c-tutorial/c-programming-interview-questions?source=next_read
CC-MAIN-2021-49
refinedweb
1,447
64.51
RationalWiki:Saloon bar/Archive41 Contents - 1 Recursive nightmare - 2 Merchant - 3 Π becomes one of the cool kids - 4 Look Everybody, I'm infamous - 5 Maus II - 6 Curse my metal body! - 7 Awesome Youtube channel - 8 Could Someone link me to a bullshit documentary - 9 Is this for real? - 10 Dynamiclear - 11 FSTDT - 12 What is your D&D alignment? - 13 Internet snoopers - 14 Prison fellowship - 15 Email - 16 Which logical fallacy is this? - 17 Pink slip campaign - 18 SMBC - 19 Right-wing paranoia - 20 Only a Matter of Time - 21 Bot request (really lame) - 22 Fetch the party poppers! - 23 I give up. - 24 On the death penalty and being a bleeding heart liberal - 25 Remembrance Day - 26 protecting high use templates - 27 Does anyone else think Kent Hovind is funny? - 28 Get out of my head, RW! - 29 Matt Bors - 30 In case anyone followed this story a while back... - 31 Another reason I'm no longer a practicing Catholic... - 32 Nice to see climate changes is not occurring - 33 Fundies, Fundies everywhere, and not a brain to think - 34 "Do as we say, not as we do", Part XXXVIII... - 35 So hi - 36 Onion: Portrait of a teabagger/birther - 37 Dr. George J Georgiou, Ph.D.,N.D.,DSc (AM).,MSc.,BSc - 38 Did I make a good point? - 39 There's never a bad time to link to Icanhascheezburger - 40 anybody want to play? - 41 Dembski's vague wackings off - 42 New Scientist on Swine Flu myths - 43 Isaac Asimov - 44 6th sense - 45 I cut a piece of paper in half with another piece of paper - 46 Quick brag - 47 Gold Standard Video - 48 For UK RationalWikians - 49 Magnetic water treatment - woo? - 50 Capturebot space saving proposal? - 51 Procrastination - 52 Meet "A Conservapedian" Live this Wednesday... - 53 Quote Recursive nightmare[edit] I thought you'd all enjoy this one I uploaded from the awesome Armstrong and Miller. CrundyTalk nerdy to me 21:41, 7 November 2009 (UTC) - I hate when that happens, totally fucks with my lucid dreaming. My record is about 4, once even managed to get up, dressed and all the way to work before I realised I was still asleep. postate 23:37, 7 November 2009 (UTC) Merchant[edit] My eyes are filling while watching The Merchant of Venice! Does that make me a sentimental old moo? (I do feel sorry for Shylock though) I played Nerissa in the school play - a (hell of a) while ago! & marmitechat 01:25, 8 November 2009 (UTC) - - I'm watching Kurosawa's Ran right now, and I'm just being overwhelmed by the sheer artistry of it all. --Kels 02:01, 8 November 2009 (UTC) - Frost/Nixon, me. Sterile largely defensive weapon of gun 02:02, 8 November 2009 (UTC) - I have got to get my own copy of Being John Malkovich.--Thanatos 02:27, 8 November 2009 (UTC) - Shouldn't that comment be in the section above? ;) ħuman 02:29, 8 November 2009 (UTC) - PPPPPS, I thought this section was about Natalie. ħuman 04:08, 8 November 2009 (UTC) - And I thought the title was rhyming slang. Merchant banker. Totnesmartin 13:22, 8 November 2009 (UTC) Π becomes one of the cool kids[edit] This is my first edit free of the Microsoft shackles. I just wanted to share that with you all. - π 12:01, 6 November 2009 (UTC) - It's very liberating, isn't it? Tetronian you're clueless 12:51, 6 November 2009 (UTC) - DON'T DO IT PI!!!! --The Emperor Kneel before Zod! 12:58, 6 November 2009 (UTC) - - (EC) @Tetronian It looks kind of like a fancy new version of windows. It is nice to see that GIMP, Firefox and a lot of other things I use came preinstalled. GIMP especially without the annoying long load time. I am contemplating whether to wipe my uni computer and install Ubuntu on that. Upside, I will have a computer that works. Downside, ITS will lose their shit if they find it, not because it is wrong, just because it wouldn't fit into their Mac/Windows world. - π 12:59, 6 November 2009 (UTC) - Ah another Firefox fan? Good, good. Strangely mine didn't come with the GIMP though, I had to download it. Personally I have to wonder how many more years Microsoft can stay afloat, particularly if Windows 7 isn't as good as they say. I just don't see how they can compete with Mac/Linux. Tetronian you're clueless 13:06, 6 November 2009 (UTC) - Pretty much because the only way you can buy a complete computer is with Windows installed and you have unwittingly paid out a couple of hundred for a licence. I built this box myself, but I still installed XP on it. I think the next box I build I will go straight to Linux. I tried Vista once and I am unwilling to ever try another new Windows again. I was told that Vista is quite good if you set it to Windows classic so that it looks like 2000. - π 13:11, 6 November 2009 (UTC) - I've never used a Windows computer significantly; I used a Mac until recently, then Ubuntu. Stupid evil Phantom! 13:32, 6 November 2009 (UTC) - I'm very happy with Ultimate 7. (Especially as I got it for free.) I was tempted to go for Ubuntu while I still had Vista, which drove me crazy, and probably would have if I'd have had to pay for 7. It was being too lazy to figure out compatibility that always held me back. Fox 13:37, 6 November 2009 (UTC) - windows is the superior operating system *runs for the hills ĵ₳¥ášÇ♠ʘ is out of his mind 14:11, 6 November 2009 (UTC) - WHAT?? *spasms wildly* (But seriously, what makes you say that?) Tetronian you're clueless 14:19, 6 November 2009 (UTC) - I used Linux from the time RedHat 5.2 was out to about four years ago, and while I liked it and all I found it much tougher to use than Windows. I've tried RedHat (up to the point they got seriously proprietary), Mandrake, Slackware and OpenSUSE, and they all required a rather daunting learning curve for someone like me who's not very technically minded. When I moved and no longer had someone I could call at short notice for technical help in figuring this stuff out, I quickly foundered. If you're into the tech and have a head for that sort of problem solving, I'll easily say Linux of whatever variety is superior, but if you're not, then it's not. --Kels 15:19, 7 November 2009 (UTC) - Ubuntu is totally load & run. You don't need any know-how (I can use it for Drake's sake). I think it was the users who complained along those lines that made someone do it. The sheer amount of free software and the ease of installing it is enuff reason to use it& marmitechat 15:57, 7 November 2009 (UTC) - That's exactly what I was told about RedHat, Mandrake and OpenSUSE, so forgive me if I'm a bit skeptical. The time I tried to install a webcam still haunts me. --Kels 16:02, 7 November 2009 (UTC) A note to PI. You can buy a complete custom computer from any number of vendors without an operating system installed, including these guys ( from whence I got my last gaming machine. NOTE: This is not an endorsement, I wouldn't recommend them over any other gaming machine vendor. I've had the typical number of problems from them, but they re an example of a vendor with the option of buying their machines sans Windows. Me!Sheesh!Mine! 14:51, 6 November 2009 (UTC) Π the n00b asks stupid questions[edit] What is a good Latex editor for Ubuntu and do I need a compiler or does one come preinstalled? - π 23:14, 6 November 2009 (UTC) - Assuming you've got Karmic Koala. Take your pick. & marmitechat 23:30, 6 November 2009 (UTC)] - I'm a big fan of emacs+AUCTex+xdvi. I've also heard good things about Kile -- it's a KDE app but I think it'll run under gnome. I assume ubuntu has it in their repos. --Pyfgcr 23:34, 6 November 2009 (UTC) - Editor fans are worse than OS or browser fans. & marmitechat 23:39, 6 November 2009 (UTC) - Thanks Toast. I just got my new editor installed, works great. No lengthy install, everything I needed was there. - π 23:45, 6 November 2009 (UTC) - It's fun to wander round the "Software centre" (& note the spellinge) & marmitechat 23:49, 6 November 2009 (UTC) - It occurs to me that the spelling might be 'cause I've specified Brit English on my install. Is it "center" on US install? & marmitechat 00:08, 7 November 2009 (UTC) - - Know what's a really good editor? WinEdt. (Joking aside, Kile is good.)-- Antifly Merged with Infinity 02:04, 7 November 2009 (UTC) - If you don't use vi you're a pansy. DogPMarmite Patrol 08:03, 7 November 2009 (UTC) - I used LaTeX manually, and I still do for complex documents, but mostly it's LyX for me nowadays. It looks like a clone of Wordpad, but it's actually very user-friendly, and you can still insert LaTeX-code manually if you wish. Give it a try for a week or two. Pietrow 11:59, 9 November 2009 (UTC) Look Everybody, I'm infamous[edit] So a while back I contacted this blogger about my story. We met, he recorded and took notes, and the final product is now available right here. Gotta say, I wish he hadn't used quite so many quotes... It comes off pretty harsh, I sound like a Black Panther.... Either way, I can't help but smile. I figured I'd give him the old RW Bump, so I hope you guys check it out. SirChuckBThis country needs more Rutabegas 20:12, 6 November 2009 (UTC) - Way to go Chuck! Although the blogger does come to the conclusion that you are exaggerating... Tetronian you're clueless 20:24, 6 November 2009 (UTC) - TL;DR. Who's the guy with the chip on his shoulder in the video at the bottom, btw? Fox 20:28, 6 November 2009 (UTC) - I know, right? ;) — Sincerely, Neveruse513 / Talk / Block 20:29, 6 November 2009 (UTC) - Fox you should definitely read it, it was very interesting. Tetronian you're clueless 20:32, 6 November 2009 (UTC) - - Yeah, and as I think about it, I'm pretty sure that I'm letting my anger at the way I was treated affect the way I'm remembering a lot of my time there.... But I still stand by my statment. The counselor is a liability and should be fired... But oh well... and the bottom is my stand up... Don't take that as anything but pure comedy... Pretty much everything in that clip is made up. SirChuckBThis country needs more Rutabegas 20:37, 6 November 2009 (UTC) - I like you better in Harold and Kumar Go to Whitecastle. — Sincerely, Neveruse513 / Talk / Block 20:45, 6 November 2009 (UTC) - Zero, I don't know if that's complimentary or creepy, but I'm gonna air on the side of caution and say thank you for the nice compliment. :) and I wasn't in Harold and Kumar, Neveruse, I was in American Pie. SirChuckBThis country needs more Rutabegas 20:57, 6 November 2009 (UTC) - It was mostly meant to be sarcastic. I totally don't have a shrine built to you in my bedroom, complete with artists conceptions of what you look like. Cause that would be weird. Z3rotalk 22:57, 6 November 2009 (UTC) - I have such a shrine. ChuckB is my hero. ħuman 03:29, 7 November 2009 (UTC) - Zero, I had guessed as much, I was just trying to keep the joke going... and Human, that's SIR ChuckB to you. SirChuckBThis country needs more Rutabegas 08:24, 7 November 2009 (UTC) What I don't understand is why you're wearing clothes. I mean, the rest of us are naked, right? If you needed pockets to hold your chapstick you could have just gone with a man purse. Me!Sheesh!Mine! 13:49, 7 November 2009 (UTC) - Good post. I really like the conclusion that we're moving away from blatant displays of racism and into something a lot more subtle (and just as, if not more problematic) and almost unconscious. It's these small left overs of a much less subtle time, but it's going to take a while yet for it to fizzle out to nothing. postate 19:34, 7 November 2009 (UTC) - I agree Armond, it was great... I think I got some rough treament... I lot of my qualifiers and track back statements got erased and I sound really awful I think, but oh well..... I guess Jim got a few nasty emails from the counselor involved. He won't show them to me, but he said they were full of personal invective against me and ended with (of course) a request to take the whole post down. Jim said it was funny because he didn't answer hardly any of the points I made. SirChuckBThis country needs more Rutabegas 20:05, 7 November 2009 (UTC) - I think it was well-written and interesting, and I don't think he was as hard on you as you think - presenting the counselor as a threatening, lawyering-up anger head was a pretty subtle way of showing who he really believed without giving up his pretense to neutrality. ħuman 20:10, 7 November 2009 (UTC) - Yeah, he definitely wasn't too harsh on Messr Charles B. Saying that he can only really tell "his side of the story" is a little chiché and a cop-out, but it's the only decent appraisal of a situation you can give without blatantly taking sides and dropping into some very black and white (no pun intended, srsly) thinking - which wouldn't help in this situation. If "Casey" did ask for a take-down of the post, and the only email worth putting up mostly concentrated on threatening legal action, that's quite suspect I think. postate 20:22, 7 November 2009 (UTC) - Never really thought of it like that... But I certainly see what you mean... I'm really pushing Jim to show the emails, but he won't do it.... I really wanna see them. I guess Casey sent a really long response, but then ended with "please don't post this." Jim wants to run it, but won't do it without permission..... Maybe it's time to bring back Boom Goes the Dynamite. SirChuckBThis country needs more Rutabegas 20:35, 7 November 2009 (UTC) PS: Now that I ponder a little more, I think Casey made things worse with his response.... I mean, if someone sends a message asking for comment and you reply with "I have no comment, but I'm calling my lawyer" it doesn't exactly warm up their opinion.... and after hearing all I had to say... - You're black?! I'm kidding... I remember you getting fired and telling us about it here - we all bought you drinks. And it was really five months ago? How time flies... Good job with the article, Casey sounds like a dick, and as for your stand up, it's pretty damn funny. Drawing from real life experience is the good way to go. Keep it up.SJ Debaser 13:43, 8 November 2009 (UTC) - Thanks Josh. I love that the article is up. I think he did a good job of being balanced and now I think Casey is gonna show his true colors for the world to see. I'm hoping he tries to sue me. It'll be great for my career. As for the job thing, yeah, that was back in May. Crazy isn't it? So much happens in such a short time. Also, another thanks for the comment about my comedy. I'm really excited about getting it going again. I learned from one of my comedy heroes, Bill Cosby, that the key to good stuff is to take everyday experiences and just exaggerate it enough to get a laugh, but keep it plausible. Wish me luck as I keep going. SirChuckBThis country needs more Rutabegas 20:08, 8 November 2009 (UTC) - Do you plan on uploading any more to Youtube? I subscribed just in case, as I also found it excellent, especially for a first time. I'd literally be a bag of nerves. Literally. Dreaded Walrus t c 20:58, 8 November 2009 (UTC) - I hope to, but I've been concentrating a little more on school and theatre... But I will do more and upload them asap. SirChuckBThis country needs more Rutabegas 23:46, 8 November 2009 (UTC) Maus II[edit] Wow, what a horrid weekend I had. I felt the need to vent this one in the bar because I feel really bad. Basically, the wife screamed to me saying that the chickens had found a dead mouse (they often come across ones left behind by the cat and run around after each other trying to eat it) and so I went out with a bag to take it off them and throw it in the bin. As I was just approaching the chook who was currently dribbling the ball I heard a squeak (as she bashed it hard against the patio) and so I quickly took it off her only to find it was still alive. Yup, they'd cornered a little field mouse and were in the process of ripping it apart, alive. I held it for a bit, realising that just about every bone in its body was probably broken and that I really should put it out of its misery. Unfortunately by this point I had an audience, including the wife's very young niece, and was told to bring it inside. They kept it in a box for a while until it came round, and it was dragging itself around the box (obviously had a broken back, and one broken front paw, and by the feel of it, its ribs were all smashed up as well). So after the sister-in-law had left with the kids we realised we couldn't leave it and had to deal with it. I couldn't bring myself to whack it with a shovel, and so I put it in a bag, expelled the air, and filled it with the CO2 being expelled by a rather violent wine I have on the go. It stopped breathing after about 20 seconds and a few twitches, and so I think I did what I could. Unfortunately I love animals, and rescue mice from the cat all the time (unharmed, he likes to play with them when he brings them inside) and am now feeling guilty about killing one "Nazi gas chamber style". Help! Feed me some reassurance! CrundyTalk nerdy to me 19:27, 8 November 2009 (UTC) - Here's some: you did everything you could to ensure that the mouse died with as little pain as possible. You could have left it for the cat or just allowed it to die slowly and painfully. Instead, you gave it a quick and less painful death. Though it may have seemed cruel to you, try to imagine it from the mouse's perspective - the "gas chamber" is probably the most pain-free death it could have had. - I probably shouldn't mention this, but when I read your post your sig's talk page link said "putting the cute in execute." Tetronian you're clueless 20:23, 8 November 2009 (UTC) - Shoulda let the chickens finish the job. It's that random "non chicken feed" diet that makes their eggs to awesome. ħuman 20:27, 8 November 2009 (UTC) - @Tetro: Lol @ my random talk line. I guess I should remove that now. @Human: You're a bad person, and besides, their cat-poop diet is what makes the eggs so special. CrundyTalk nerdy to me 20:48, 8 November 2009 (UTC) Moarmore lols: when I reloaded the page just now, it said "at least I have chickens." Is it a day for weird coincidences, or what? Tetronian you're clueless 20:50, 8 November 2009 (UTC) - Chicken! At least I have chicken! Y'know, from Leeeeeeeroy jenkiiiins! CrundyTalk nerdy to me 20:52, 8 November 2009 (UTC) I sympathize with your squeamishness but I loathe rodents of all varieties (yes, even squirrels) so you did me a favor in the most gentle way possible. Thanks for that. Me!Sheesh!Mine! 20:59, 8 November 2009 (UTC) - Ohhhhhhhh. I get it now. Tetronian you're clueless 21:00, 8 November 2009 (UTC) - It's not squeamishness, it's just a sense of guilt. Ffs, I studied pharmacology at uni and was experimenting on whole guinea pigs, lung suspensions, and illeum without a care in the world. It's just the action of killing the poor things in the first place. It's not for me. CrundyTalk nerdy to me 22:09, 8 November 2009 (UTC) - I can't help but agree that killing things is difficult. I also have that problem, unless the target is of the insect variety. You did the best you could, considering the fact that left to its original fate, it would have suffered much more than anything you would have done. The gas effect was probably the best option, as the creature didn't suffer any more than it already had. I doubt that any kind of rehabilitation for the mouse would have had any effect, as it was so near to death anyway. Aboriginal Noise Punkrock 01:40, 9 November 2009 (UTC) - Our cats regularly bring meeces & voles and the odd sparrer. I've rescued and released several but most are beyond recall when I first see them. The first time I had to kill a sparrow I was sick afterwards (literally sick as in vomiting) - not from squeamishness but from guilt. btw, I smashed its head with a hammer. & marmitechat 01:58, 9 November 2009 (UTC) - Nature happens. It's not really our place to interfere unless it's one one of your animals (to which you owe some responsibility). I know it's sometimes difficult but we shouldn't try and impose our ethics on other species. Some of the cameramen for the BBC Life series had similar feelings when filming predators in the wild. It's tough but it's going to happen whether we're there or not. I had a similar experience when one of my dogs caught a rabbit and broke its back. I probably caused the rabbit more pain by trying to kill it than if I'd let the dog eat it there and then. A similar thing happened when one of our cats caught a rabbit and failed to kill it. I was away but some vegetarian friends of my wife were staying and ended up clobbering it with a brick. They were quite traumatised by it and were glad to get back to their urban utopia away from the nasty countryside. ГенгисRationalWiki GOLD member 09:21, 9 November 2009 (UTC) - Well, that's the other thing. It isn't really 'natural' for chickens to do that. The problem is, they've been bred to be mindless zombie eating machines which will ruthlessly kill and devour anything organic in sight. Cat shit, plants, frogs, mice, fish food out of the pond, and recently each other (one was eating the arse feathers out of the other). They really are horrid horrid creatures. CrundyTalk nerdy to me 10:38, 9 November 2009 (UTC) Live chickens are indeed foul (hehehe) but they make up for it by being tasty when dead and giving up their embryos which are also tasty. Me!Sheesh!Mine! 13:59, 9 November 2009 (UTC) Curse my metal body![edit] I've just been over to this lovely little wiki, and I think they could really use an infobox to go on their character pages. However, I have no clue whatsoever how to create one. I took a look at the documentation on WP, and didn't understand it one little bit. It's clearly not designed for someone who's not hip-deep in wikicode on a regular basis, nor is it really a how-to at all. I checked a couple of the templates here, but I'm still in the dark. Can someone give me a hand? --Kels 01:13, 9 November 2009 (UTC) - I could polish up CUR's magic do everything box for you? - π 01:22, 9 November 2009 (UTC) - Magic box? If it works as a sidebar infobox thing, then I'm all for it. And, of course, providing I can understand it in any way. --Kels 01:26, 9 November 2009 (UTC) - It was suppose to but he never got it working. I'll have a play with it. - π 01:28, 9 November 2009 (UTC) - I appreciate it. I'm mainly interested in giving a little quick info for various characters. Series, first appearance, place of origin, that sort of thing. --Kels 01:30, 9 November 2009 (UTC) - I am pretty sure I can do it as a html table. It might take me a bit more time, though. - π 02:58, 9 November 2009 (UTC) - Well, it may not be necessary over there since it looks like one of the guys there is working on a version. But it would come in handy here in any case, so worth working on all the same. Thanks so much for the effort. --Kels 03:00, 9 November 2009 (UTC) - Oh well, I have all the mechanics in place now at Template:Infobox and Template:Infoboxline. Need prettying up though. 03:04, 9 November 2009 (UTC) - I read that webcomic, too! Come to think of it, you might have even been the one who pointed me in that direction. --The Emperor Kneel before Zod! 02:10, 9 November 2009 (UTC) Awesome Youtube channel[edit] I stumbled upon this channel the other day. Loads of good doco's. AceMcWicked 03:22, 9 November 2009 (UTC) Could Someone link me to a bullshit documentary[edit] I have a love-hate relationship with bullshit documentaries about supposed paranormal activity that exaggerate things and pull information from unreliable sources. I think they're fraud, but they also amuse me in a horror-movie sort of way. But, I don't know the names of any such documentaries I haven't seen, so I can't type them into Youtube. Could anyone give me a name or link? (I've already seen "Vampire Princess")--Mustex 01:56, 8 November 2009 (UTC) - This one is horrifying. 02:43, 8 November 2009 (UTC) - Seen it. And I'd prefer vampires/ghosts/mummy curses/whatever (maybe aliens on a stretch). Horror movie stuff.--76.18.115.64 02:48, 8 November 2009 (UTC) - Ever seen Jesus Camp? Horror to me. --The Emperor Kneel before Zod! 03:10, 8 November 2009 (UTC) - Yeah I've seen it, but not really the type of horror I'm feeling like.--Mustex 16:54, 8 November 2009 (UTC) - No titles come to mind, but the TV channel Discovery Civilization used to be pretty notorious for airing bullshit. I recall one in which Erich von Däniken was given free reign to push his ancient astronauts theory with nothing in the way of serious criticism. Their late night paranormal stuff is also pretty bad, normally with the narrator trying to be so neutral. Their "perhaps we'll never know" phrases are overused to the point where the narrator appear to have the credulity of a very poorly educated child. Jesus Camp is actually a pretty fairly balanced documentary, with the fundies providing the rope that hangs them. --Ask me about your mother 11:48, 8 November 2009 (UTC) - Oh, check out Loose Change and Zeitgeist. You'll probably find them on YouTube. Farenheit 9/11 also contains some rather dubious facts.--Ask me about your mother 11:51, 8 November 2009 (UTC) - If you stick "paranormal documentary" into YouTube I'm sure you'll get loads. I found one a few months ago on aliens being among us (I too still have a weakness for watching these things) but I cannot remember what it was called. You could possibly look up Arthur C Clarke's documentaries from the 80s and early 90s as they report paranormal stuff including vampires and so-on. postate 11:53, 8 November 2009 (UTC) - This came into my inbox this morning. Totnesmartin 13:24, 8 November 2009 (UTC) - Ahahaha that guy has obtained an alternative PhD in Transpersonal Counseling (Psychology), a Masters in Metaphysical Science, a diploma as a Mind Science Healer. He is also a Certified Hypnotist and a Certified Paranormal Investigator. He also has a degree in Assclown Studies. 20:36, 9 November 2009 (UTC) Is this for real?[edit] Gene Ray's twitter page. - π 06:27, 9 November 2009 (UTC) - I just saw that on Pharyngula. It seems nutty enough to be true. –SuspectedReplicantretire me 08:29, 9 November 2009 (UTC) - It looks like someone was pulling random quotes of the website and twitting it, but gave up out of lack of interest. I would say it is fake, but he is so serious time cube even appearing on TV to defend it. - π 08:38, 9 November 2009 (UTC) - 95% sure it's fake. It's just pulling random strings out of the main website. postate 19:34, 9 November 2009 (UTC) - Looks faek to me. WēāŝēīōīďMethinks it is a Weasel 19:37, 9 November 2009 (UTC) Dynamiclear[edit] As a coldsore sufferer, I tend to get people sending the latest gimmicks to help, the most recent of which is "Dynamiclear". Having a quick scan over, it just seems to be St Johns Wort and lysine, so not looking too good so far. They claim that it has been proven in clinical trials, but the only reference I found to this is on their site and looks a bit simplistic, as well as not being double-blind and against "leading brand" and not a placebo (look under "Study Synopsis"). In addition, a few things catch me: 1) Googling the name shows up loads of links which use the name and either "scam" or "hoax" in the title, but then go on to give a glowing review of it. I suspect the company has deliberately flooded the interwebs with positive reviews to show up when people Google "Dynamiclear scam", which is a questionable tactic at best, and 2) Their entire website has a "antiselect" javascript code block to stop you copying and pasting data. If this was legit then they would actively encourage people to copy and paste the wonderful data from their site. What do you think? CrundyTalk nerdy to me 15:09, 9 November 2009 (UTC) - I think you now know why you shouldn't make out with strange goats. 15:35, 9 November 2009 (UTC) - Dyknow, I got infected before I'd kissed a girl, which means that I must have picked it up from some aunt (or even that uncle) slobbering over me as some kind of greeting. Oh for a time machine. CrundyTalk nerdy to me 16:05, 9 November 2009 (UTC) - Most men have their first goat experience before sexual contact with a female. This is normal. 16:13, 9 November 2009 (UTC) - Anyway, stop banging on about me shagging goats and answer the damn question! CrundyTalk nerdy to me 16:31, 9 November 2009 (UTC) - ."" That's pretty much what happens if you don't do anything anyway, isn't it? By the way, any "medicine" web site that features a "doctor of naturopathy" in a nice white coat is almost certainly a bunch of deceptive woo. Also also, if there really was an effective treatment for herpes sores, the ads would be all over TV because there's a huge market. ħuman 18:55, 9 November 2009 (UTC) - I agree. All these kind of people do is find a plant which has some references somewhere saying it might help a particular ailment, and then they put a pharmacologicaly irrelevant dose into, for some reason, usually some topical (cream, lotion etc) and then flog it at an inflated price knowing that anyone who questions its efficacy can just be told "look, here's some examples of how good the ingredients work". CrundyTalk nerdy to me 21:17, 9 November 2009 (UTC) FSTDT[edit] I'm 100% sure someone here has already bought this up, or users from this site are editors at this site, but we're linked to on the homepage of "Fundies Day The Darndest Things." SJ Debaser 15:11, 9 November 2009 (UTC) - Already noted on the article. Or at least the footnotes postate 15:22, 9 November 2009 (UTC) - Yeah, I'm so lazy I didn't even bother to check we had an article on them. I love being the last to find these things =) SJ Debaser 17:14, 9 November 2009 (UTC) - Well, thanks for reminding me about them antyhow. I've just spent a happy 15 minutes or so going through some random quotes. Phil isn't the maddest twatcur out there. & marmitechat 17:26, 9 November 2009 (UTC) - I'm one of those people who is an editor at both. There's a lot of stuff as fstdt that makes CP look like the height of rationality. My all time favorite was one from a woman who was very very concerned about her teenaged son. It seems she found magazines with pictures of scantily clad men in his room. This worried her, because her son was much too young to be dating, because obviously he had a girlfriend who was leaving the magazines there... Its not just a river in Egypt, folks. MDB 18:10, 9 November 2009 (UTC) - My only problem is that after a while you get desensitised to the insanity. I find myself thinking "Well that's stupid but not head-spinningly insane so I won't vote for it", even if the quote in question would normally result in a tea-drenched keyboard. –SuspectedReplicantretire me 18:13, 9 November 2009 (UTC) Tolerance[edit] Quite a few people have posted lately about developing a "tolerance" to the insanity they see on various webshites. I think this is an interesting topic we should explore in depth, maybe even write an article on it. ħuman 18:59, 9 November 2009 (UTC) - Someone qualified in scientific analysis needs to perform a proper, peer-reviewed study to confirm our assumptions. Then it'll be science! Z3rotalk 19:15, 9 November 2009 (UTC) - The whole thing about being desensitised? Perhaps. After all, you check WIGO:CP and relatively new watchers are like "OMG!! LOOK AT THAT BLOCK REASON??! JUST FOR TALK TALK TALK?!? LOL" and everyone else is like "meh?". postate 19:28, 9 November 2009 (UTC) - I don't mean CP - I mean religious insanity in general. I found myself (yesterday) talking to somebody and saying that Old Earth Creationism was a reasonable point of view. It's not. It's really not. It just seems that way compared to the YEC of Andy and PJR. On FSDT... well let me pick one: "[Would you care to explain for me then? Are Christians more honest than everyone else in the world? Jews, Muslims, other religions and non-believers are all less honest and greedier than Christians?] NO OF COURSE NOT, I ONLY SAID LOWERS THE ODDS, AS CHRISTIANS ARE TAUGHT TO ABHOR EVERYTHING IN THE WORLD AND TO NOT BE LOVERS OF MAMMON. OUR ATHEIST DRIVEN SOCIETY TEACHES US TO BE MATERIALISTIC. AND YES OF COURSE JEWS ARE GREEDIER. IF YOU HADNT NOTICED THAT YOURSELF YOU REALLY ARE BRAINWASHED LOL - Now, that appeared on the Yahoo! Manchester United board so I have an instinct to vote it up on football rivalry alone, but despite the egregious misuse of words (I assume he meant "adore", not "abhor") I still didn't vote "WTF!" on this one because there is far, far worse. Does this mean I now accept positions like this? That I ignore them? I am honestly worried about this. - Before I joined RW I thought - I honestly thought - that YEC was a joke. Having "met" people like Andy and PJR, and experienced the paranoia of people like RobS... the "average" opinion I've experienced has shifted so far to nuttery that even OEC appears sensible. If I've taken anything from this site it is the knowledge that there are many people out there that share my open-mouthed, horrified disbelief at the bullshit that flows from these idiots. That's the main reason I had a need to come back after I fucked up under my usual nick of rpeh. I don't agree with all the politics that appear on here, but we can all agree on a solid, rational base for the universe and its marvels. That is an incredibly valuable thing. –SuspectedReplicantretire me 20:02, 9 November 2009 (UTC) - He meant "abhor" not "adore". WēāŝēīōīďMethinks it is a Weasel 20:25, 9 November 2009 (UTC) - I can't tell. I thought Christians were supposed to love everything? –SuspectedReplicantretire me 20:39, 9 November 2009 (UTC) - CP was just an example. You can definitely start off thinking "come on, no one really believes the Earth is 6000 years old" and then you're like "oh shit, they really do" and eventually someone out there declares that they're YEC and you don't care. Then they say the Earth is flat and the cycle starts again. Right now, I feel I wouldn't be shocked if someone genuinely though that the sky was a carpet painted by god. The level of crap I've seen just makes me immune from 95% of everything out there that would make otherwise sane people curl up and cry. postate 20:14, 9 November 2009 (UTC) I see where Hooman is coming from, but I think the opposite also has rays of truth; we're becoming intolerant of teh crazy. Recently, it's dawned on me (again) that Andy actually has serious mental problems, yet we still point and laugh like it's a big joke and he's just an idiot. Ken is also similarly insane, and sometimes I think Trent should be a little more scared than he might already be. They're complete insanity is normal to us and we pawn it off like it's not a serious (perhaps even debilitating) problem for a real, live persons.— Sincerely, Neveruse513 / Talk / Block 20:20, 9 November 2009 (UTC) - That didn't make a whole lot of sense. — Sincerely, Neveruse513 / Talk / Block 20:22, 9 November 2009 (UTC) - I get what you mean. And I'd agree with you if some of these people weren't in po3 Internet 1sitions of authority. Andy teaches children. He teaches this shit to children. "Don't listen to facts - listen to ME". Ken is clearly in denial; RobS is paranoid; Karajou has masses of barely-repressed anger at not getting more promotions; TK is a parodist; Ed is... I really dunno - he had teh powah at WP and lost it. The point is... what is it all doing to us? –SuspectedReplicantretire me 20:39, 9 November 2009 (UTC) - I think it is doing two things: first, we are desensitized to craziness, as is thoroughly proven by ArmondikoV above. We have more exposure to fundies than most people, and are less amazed/amused by them and their beliefs. However, I think we do have a distinct anti-fundie (and perhaps also anti-theist) bias that comes from reading and writing RW articles and participating in discussions. I think we have a tendency to feed off of each other and form something similar to groupthink. Compare a new user to one who has been here for a while: the former will have not yet formed an opinion on CP and similar craziness, while the latter has a condescending attitude to such things and is impatient with anyone who does not see the craziness of fundamentalism. Also, we are more aware of the extent to which fundies are influencing policy (which is a paranoia of sorts), which makes us angrier and more paranoid about it (if that makes any sense). Tetronian you're clueless 21:55, 9 November 2009 (UTC) - I Think that developing Tolerance is a Good Thing.--Tolerance 22:02, 9 November 2009 (UTC) - Sometimes, but not always. I'm about as tolerant of kid rape as I am for teaching children that science is a big conspiracy. — Sincerely, Neveruse513 / Talk / Block 22:04, 9 November 2009 (UTC) - Tolerance, the "tolerance" referred to in the header is not that kind of tolerance. It's like the kind of tolerance one develops to a drug, for example. If someone drinks a lot, their tolerance goes up - it takes more alcohol for them to get "high". In our case, it takes more batshit lunacy to make us say "wow, that is crazy", because we absorb so much it. ħuman 22:31, 9 November 2009 (UTC) - Well, at the end of the day, someone who has never encountered a creationist (at least in the UK) would be shocked that they actually believe the earth is only 6,000 years old and that evolution is a big government conspiracy, whereas we would just be like "Yup. That's what they're like" when we spot a psychotic wingnut statement. CrundyTalk nerdy to me 00:49, 10 November 2009 (UTC) - Some things I think I have been desensitized to, other things make me cringe every time. Sterile largely defensive weapon of gun 03:06, 10 November 2009 (UTC) What is your D&D alignment?[edit] As for myself, I am "Neutral Good/Lawful evil" (it was a tie). Go knock yourselves out Javasca₧ <insert witty comment here> 19:09, 9 November 2009 (UTC) - D&D alignments are bullshit anyway. Yeah, because chaotic good and lawful good are so different. I'd be chaotic evil just to kill the kind of people that make these quizzes. Z3rotalk 19:12, 9 November 2009 (UTC) - I knew today was going to be weird, and sure enough I appear to be back in 2002.--Tom Moorefiat justitia 19:24, 9 November 2009 (UTC) - I can't get it to give me a result at the moment. I guess "Chaotic Good" though. I'll try again later. –SuspectedReplicantretire me 19:43, 9 November 2009 (UTC) - I'm neutral evil apparently. Kif, what makes a man turn neutral? --JeevesMkII The gentleman's gentleman at the other site 21:27, 9 November 2009 (UTC) - Ditto. It's not loading particularly well for me, but I guess "chaotic good" from the questions and answers. I may end up with "neutral" considering I rarely click the extremes (1 and 5) on this sort of quiz. postate 21:41, 9 November 2009 (UTC) - Lawful evil (with neutral good close behind). Stupid evil Phantom! 22:10, 9 November 2009 (UTC) - I have been playing a ROM of Shin Megami Tensei II for the SNES and my alignment shifted to Lawful, despite me being a believer in Chaos. I am too much of a good guy (and I shouldn't have started recruiting angels). Now I got to build YHVH's Thousand Year Kingdom.--Thanatos 00:08, 10 November 2009 (UTC) - Lawful evil/chaotic neutral. I'd rather be a lich. --The Emperor Kneel before Zod! 00:53, 10 November 2009 (UTC) Internet snoopers[edit] I am having a hard time with a cursory glance and a bit busy...but if anyone is bored and wants to try their hand at some internet snooping I am looking for an e-mail contact for a man named "Sid Ryan" who is the president of CUPE ontario. He is a public figure so there should be something....tmtoulouse 02:09, 10 November 2009 (UTC) - How deep do you want us to dig? He haz wickypedea artikle. ħuman 02:33, 10 November 2009 (UTC) - His phone number is here. ħuman 02:36, 10 November 2009 (UTC) - It's sryan@cupe.on.ca 02:40, 10 November 2009 (UTC) Prison fellowship[edit] I just went outside and got my mail and found that some organization called the Prison Fellowship had sent me 5 letters, each containing a brochure. According to them, Christians are "discriminated against and abused" in American prisons, and prison Bible study groups are "forced to shut down." I figure this is mostly bullshit, but I thought I would ask if anyone knew anything about it. Tetronian you're clueless 23:47, 9 November 2009 (UTC) - Seems very unlikely, but if they are being discriminated against and not being allowed to pray etc then I agree with them. As much as I hate religion I don't see what the problem is with giving people somewhere to pray and congregate. Perhaps this is one of those "creationist science teacher" situations whereby the inmates are hassling all the other inmates and trying to force them to go to their prison church, and so the guv'nor told them that they either play nice or not at all. Did they give you a phone number? Give them a bell and ask. CrundyTalk nerdy to me 00:35, 10 November 2009 (UTC) - I did some research, and apparently it is a combination of (a) bullshit claims about Christian prisoners are being abused and not allowed to study the Bible (totally untrue; US prisons allow inmates to attend religious services, but just not every hour of the day), and (b) their desire to convert people in prison to reform them via Christian faith. So it's really more of an evangelical organization than anything, which the brochures I got in the mail tried to mask. Tetronian you're clueless 00:41, 10 November 2009 (UTC) - Yeah, I can't imagine a US prison doesn't hand out bibles to everyone (even the jews and the muslims). CrundyTalk nerdy to me 00:45, 10 November 2009 (UTC) - This just in, from the curator of the "Nothing new under the sun" department: Prisoners at penitentiaries in Atlanta and San Quentin have formed the Church of the New Song (CONS). They claim that their ritual requires them to eat porterhouse steaks and drink Harvey's Bristol Cream sherry and are suing prison authorities to get the needed ingredients for their menu. Dated Monday, May. 13, 1974 Sprocket J Cogswell 14:04, 11 November 2009 (UTC) Bloody hell, HSBC have lost my details again! That's the third time this week. And no matter how quickly I go to the site and give them all my details, I still find all my money gone within an hour anyway. Honestly, no wonder the banks are in such a crisis! Apparently Nationwide lost my details as well yesterday, and I don't even bank with them. Idiots. CrundyTalk nerdy to me 14:57, 10 November 2009 (UTC) - Halifax (or whoever they are nowadays) won't lose my details: I get about 3 emails & 2 snailmails a week despite my repeatedly asking them not to. & marmitechat 15:22, 10 November 2009 (UTC) - Yeah, halifax ask me to log on as well. At least I'll have loads of cash after this Nigerian guy who contacted me gives me 10% of his dead uncle's cash or something. CrundyTalk nerdy to me 15:39, 10 November 2009 (UTC) - I haven't got time for all this banking - I'm too busy collecting the parcel that UPS were unable to deliver. Bob Soles 15:41, 10 November 2009 (UTC) - DEAR FRIEND, I'm the MANAGER of YOUR BANK. Feel free to mail me your account details, DEAR FRIEND, and I'll ensure that your account issues are resolved. bankmanager77@hotmail.com.--Ask me about your mother 16:14, 10 November 2009 (UTC) - I'm planning on using the money from the Nigerian guy to buy some Viagra at 90% off. MDB 16:52, 10 November 2009 (UTC) - Well I'm not going in to detail, but if the email I just received is right, I'm going to need underwear that's 20% more roomy than I currently wear. –SuspectedReplicantretire me 17:08, 10 November 2009 (UTC) - They should have Facebook look after their login security - despite not having a Facebook account, I keep having to change my login details with them, which must mean they're very secure. DogPMarmite Patrol 17:59, 10 November 2009 (UTC) Seriously, I got a phone call from my 79 year old father one time. Dad is about as technically literate as, oh, the flatbread chicken sandwich I had for lunch. The conversation went something like this: Dad: I just got an e-mail from Citibank that said... Me: It's a fraud. Dad: But it said that... Me: It's a fraud! I went on to give the standard lecture that no financial will ever e-mail you about your account details, to call their 800 number if you have questions and use the number on the credit card, not the e-mail, etc etc etc. I still worry about him or Mom falling for something like that... MDB 17:06, 10 November 2009 (UTC) - They're a long way from alone. Gartner estimated phishing losses for the US for 2007 as $3.2bn - M$ say this is vastly overinflated by a factor of maybe 50. So we're talking a mere $60,000,000 for 2007. - If it didn't work they wouldn't do it - oh, and I had exactly the same conversation with my 85 year old father. Bob Soles 17:22, 10 November 2009 (UTC) - My Mom and Dad aren't unintelligent, but they are rather too trusting. (Mom, for instance, was rather surprised when I explained that Eyewit lness news would not get into legal trouble for reporting something that turned out to be untrue.) I really worry that they're going to be the victim of a financial scam someday. (And not just because its my inheritance. I've told them I want them to spend it all before they go, anyway. I want them to enjoy retirement.) MDB 17:54, 10 November 2009 (UTC) - My mother-in-law is a scammer's wet dream. She outright believes absolutely anything anyone tells her, except for me and my wife. It's infuriating to have to explain to her what's going on with something when it's just common sense most of the time. CrundyTalk nerdy to me 17:55, 10 November 2009 (UTC) - My Mom's big weakness is the inability to recognize bias. For instance, she once remarked that my Uncle, who worked for AT&T for decades, said the Bell System break up was the worst thing to ever happen to the American phone system. "Mom," I said, "don't you think Uncle _____ might be a little bit biased when it comes to AT&T?" She acknowledged that, but the fact she didn't realize that someone who had a career at AT&T might be biased when it comes to a court decision that completely changed how they did business.... oy.... MDB 18:22, 10 November 2009 (UTC) - It's not that people who don't think about this stuff are stupid, it's more a case of lack of knowledge than intelligence. Once someone's highlighted certain things to you, biases, scams and ingenious trickery, you become more aware that A) they exist and B) what to look for. 90% of the time it just doesn't apply in real life so no one needs to be aware of it. postate 18:41, 10 November 2009 (UTC) - Then you run the risk of becoming overcynicall. & marmitechat 18:53, 10 November 2009 (UTC) - Of course, the only way Microsoft know that Gartner have got the numbers wrong is because they're testing this new email tracking software and will pay you thousands of dollars just for passing the info on. Dreaded Walrus t c 05:46, 11 November 2009 (UTC) Which logical fallacy is this?[edit] Speaking of the mother-in-law, I noticed something she does a lot which is really starting to piss me off. Here's an example: She will cook a large bowl of rice in the afternoon and then leave it on the worktop until the evening (about 7 hours) before microwaving it and serving it. I have told her that cooked rice needs to go into the fridge within an hour, otherwise you are at a massive risk of contracting bactillius cereus food poisoning. I have shown her health and safety websites which list rice as the number one food for causing food poisoning. So all she has to do is put the bowl in the fridge, right? What's her response? "Well, I've been doing it for years and I've never become ill". I hear a lot of people use this argument, "X is bad for you", "Well, it never did me any harm". It's basically like a "Never did me any harm" fallacy, but I can't believe it doesn't already fit into an existing category. Anyone? CrundyTalk nerdy to me 18:01, 10 November 2009 (UTC) - Possibly several, it's certainly one in its own right but the name escapes me. But, it could very well be a case of Spotlight fallacy in that you're taking your past experiences and assuming these are something to do with what will happen in the future. postate 18:18, 10 November 2009 (UTC) - Hah! "My uncle fred smoked 40 a day all his life and lived to 90". How often have you heard something like that? & marmitechat 18:19, 10 November 2009 (UTC) - At least three or four times a day, in my own head. Its a filthy, disgusting habit I regret ever starting. MDB 18:25, 10 November 2009 (UTC) - Converse accident perhaps? Although it's a very specific case, it is just a hasty generalization that past experiences apply to all experience. postate 18:44, 10 November 2009 (UTC) - It's also selective observation and has problems with the misuse of statistics (n = 1). Sterile largely defensive weapon of gun 18:58, 10 November 2009 (UTC) - One might also ask how often the Ma-in-law had a slight tummy upset or similar some time later (can take up to 48 hours for bacterial food poisoning to show) without connecting it with the rice. & marmitechat 19:53, 10 November 2009 (UTC) - I always called it the "I know a guy" fallacy. tmtoulouse 21:43, 10 November 2009 (UTC) It'd be the fallacy of false induction (WP:Appeal to tradition). — Sincerely, Neveruse513 / Talk / Block 21:50, 10 November 2009 (UTC) - Aha! That looks like it. Also from that page I like "Appaeal to novelty", which the senior developer on our team is a victim of. CrundyTalk nerdy to me 09:00, 11 November 2009 (UTC) Pink slip campaign[edit] Janet Porter's Faith2Action, after heavy promotion on WorldNetDaily, are sending pink slips to congressmen and senators about how they will lose their jobs if they pass certain legislation. They are boasting about how they have got enough donations to send over 4.5 million. A pile that would be three times higher that the Washington monument ect. But something that occurred to me this. There are 535 congressmen and senators. That means only about 8,412 people have cared enough to actually do this. Not an impressive number when you look at it that way. - π 22:33, 10 November 2009 (UTC) - That's assuming each person is responsible for an equal amount of "pink slips". That number could be much smaller if someone donated a larger portion, meaning even more pathetic. Z3rotalk 22:38, 10 November 2009 (UTC) - They are sold in lots of 535, so 8,412 is a maximum. You are right though, if some on got excited they may have bought two or three. - π 22:46, 10 November 2009 (UTC) - That's hilarious. Do we have Faith2Action? ħuman 01:28, 11 November 2009 (UTC) - We should really or at least Janet Porter. A lot of people commented that the idiot's convention looked like a torch passing ceremony from Mumma Schlafly to Porter. - π 01:40, 11 November 2009 (UTC) - Their polls are funnier than WND's. - π 01:43, 11 November 2009 (UTC) - Those polls are hilarious. I wonder if most of them are subject to Poe's Law? Then again, maybe not, because the majority of people visiting the F2A website are probably ultra-conservative... Tetronian you're clueless 02:07, 11 November 2009 (UTC) - Though only 97 people have voted over five days - hardly heavy traffic. RagTopGone sailing 11:13, 11 November 2009 (UTC) - It's considerably higher than our pointless polls and marginally higher than the upper range of WIGO:CP votes. But yes, hardly heavy traffic. postate 13:58, 11 November 2009 (UTC) SMBC[edit] ...is brilliant. Yesterday's and today's really hit the spot.-- Antifly Merged with Infinity 12:14, 10 November 2009 (UTC) - There have been some brilliant religious ones: [1] [2] and [3] for instance. –SuspectedReplicantretire me 08:21, 11 November 2009 (UTC) Right-wing paranoia[edit] I think this is a great article explaining the recent right-wing paranoia in the US. Just thought I would share it. Tetronian you're clueless 13:54, 10 November 2009 (UTC) - The article makes an interesting point with "Because these people aren’t interested in actually governing, they feed the base’s frenzy instead of trying to curb or channel it."- that's definitely the case. Regarding paranoia, there was an interesting piece of research (that popped up on an older WIGO) stating that it really is the case that people on the right are paranoid. They determined that people who identified as right-wing were more jumpy than those on the left. Although which was the cause and which is the effect still isn't known. postate 16:35, 10 November 2009 (UTC) - Very good piece, thanks for posting! ħuman 20:04, 10 November 2009 (UTC) - Thanks Human. To respond to ArmondikoV's point: I think the most interesting part - which the article doesn't talk about very much - is that the line between GOP lapdogs and true wingnuts is blurred. There are many people, most of them the "people not interested in governing" who only care about their moralistic agenda. Others, though, are more influenced by the Republican party and allow their interests to take second fiddle to the GOP's. For example, someone like Glenn Beck exemplifies the former category and Michael Steele the latter. Tetronian you're clueless 20:56, 10 November 2009 (UTC) - I read the article when the link was first posted and didn't quite "get it". My reaction was, essentially, "So the US has right-wing nutters. Film at 11." Reading it again I begin to understand the problem. In the UK, if people tried to set up the sort of tea party movement you have over there, they'd be laughed off the streets. In the US, they are gaining real political power. It must be quite scary living over there at the moment. –SuspectedReplicantretire me 21:06, 10 November 2009 (UTC) - It's not scary, it's just a bit troubling. It's not like they are going to take over the government tomorrow, it's more like the religious right is a portion of the population that is worryingly large and can influence public policy. Tetronian you're clueless 23:10, 10 November 2009 (UTC) - Hence why I've always thought that the UK has a healthy dose of cynicism to protect it from such things. People are very ready to call bullshit on anything, which is why American style patriotic pandering doesn't work. That said, the UK is usually a couple of years behind the US and perhaps the current rise of the BNP and their whole "British people first" thing might be the first sign that the collectivist rhetoric is kicking in. postate 18:25, 11 November 2009 (UTC) Only a Matter of Time[edit] Anyone know who Jeff Roberts is? Or anyone who uses this alias? He broke onto Jim's blog and post this really long rambling comment about me being a member of Rationalwiki and about how, since I hate all religious people to no end, that the problem wasn't that Casey was a racist douchebag (which, for the record, he is) but that my intense hatred of all things religious caused the problems.... It's really a beautiful site.... Anyone wanna take a crack at it? I'm too tired to care. SirChuckBThis country needs more Rutabegas 19:08, 10 November 2009 (UTC) - Hmmm, who would call RW "atheist-fundamentalist"? And obviously its someone who repeatedly brings up the LA Times article. Possibly Conservative? postate 19:11, 10 November 2009 (UTC) - No, too sensible. It's probably TK. Stupid evil Phantom! 19:14, 10 November 2009 (UTC) - Way too coherent to be Conservative.... and not one In Regards To.... Interesting though.... I feel like a detective SirChuckBThis country needs more Rutabegas 19:15, 10 November 2009 (UTC) - (EC, also add that in hindsight I agree with the above that it isn't Kenny)Actually, scratch that, he'd probably take the opportunity to plug Conservapedia directly rather than simply referring to it as a "Christian website". Perhaps PJR as he has a thing against RW and CP so would use the LA Times thing to denigrate RW without plugging Conservapedia? That's of course, assuming that Jeff Roberts (far too common a name to figure out an alias from) is from that crowd, there may be a much more general set of people who are critical of atheist blogs - and their are many who are vehemently opposed to us even existing, yet alone daring to speak - who would have RationalWiki on their radar as a matter of course. postate 19:18, 10 November 2009 (UTC) - Jinx hi Jinx! & marmitechat 19:20, 10 November 2009 (UTC) - - Is it Jim who's just responded? postate 19:22, 10 November 2009 (UTC) - Yeah, JDcl97 is him.... This should be fun. I don't think it's Jinx.... Not enough profanity or penis references. SirChuckBThis country needs more Rutabegas 19:24, 10 November 2009 (UTC) - It reads like TK minus the persistent over-punctuation. 19:28, 10 November 2009 (UTC) - (EC)What if it's "Casey"? Wouldn't take much hunting around to find that you're a member of RW and the LA Times thing is a fairly prominent reference to the site. And if they're not an established member of Conservapedia that would explain referring to it as "a Christian website" while not plugging it. Also, as the opening phrase criticizes the angle (which may have been one of the crits sent in via email) and the second and third paragraph seem to hint at some additional knowledge. And it fits in with the fact that the major players we know don't have this style. postate 19:32, 10 November 2009 (UTC) - I think I'm gonna have to go with Fox.... It's not his normal style, but Jim emailed me and said he thinks it's Fox..... SirChuckBThis country needs more Rutabegas 19:57, 10 November 2009 (UTC) - Fox, TK... whatever. It's just another piece of proof that there's just as much Conservative Deceit as any other kind. –SuspectedReplicantretire me 20:51, 10 November 2009 (UTC) Yeah, Fox was the one given to get very angry very quickly, and start saying really awful things but usually was an OK guy. It doesn't have the vituperative spite that I've come to know and love in the TKster, though, nor does it touch his typical topics authority here, etc, instead focusing on religion, which TK was never big on - I'm guessing probably Fox. --䷉䷻䷶䷈䷰䷒䷰䷈䷶䷈䷡䷶䷀䷵䷥ - Also, didn't Fox get pissed at you and make a "kill whitey" reference? Maybe he has a bit of a vendetta going on? CrundyTalk nerdy to me 09:08, 11 November 2009 (UTC) - To my mind it doesn't read like any of the usual suspects at CP. It isn't vituperative enough for TK, too educated for JPatt or Jinx, not enough verbal constipation or spamlinks for Ken. I also think it is written by an American rather than a Brit - note the use of 'Z' in words like patronizing or phrases like "big bucks". Also not knowing much about the blog I wonder who at CP would be reading it, has it been highlighted somewhere. It doesn't seem like the sort of thing that most of them would be reading in the first place. On the other hand the author clearly knows something about Chuck's activities here and CP's distorted view of us. Perhaps Geo.Plrd (Geoffrey = Jeff?). ГенгисRationalWiki GOLD member 11:03, 11 November 2009 (UTC - He makes pointed reference to our alleged hypocrisy of tolerance which was Fox's last fixation when he was on his bender. Also, while I don't really know him it seems just the sort of dickhead move he would do when his dander is up. Me!Sheesh!Mine! 14:10, 11 November 2009 (UTC) - Well several people have also made similar accusations and I don't believe Fox would have used US spellings. ГенгисRationalWiki GOLD member 21:02, 11 November 2009 (UTC) Just curious, but is it possible that it's someone like Bradley over at ASK? Mostly in terms of writing ability. --Kels 02:04, 12 November 2009 (UTC) - Jim emailed me and said that he was 100% certain it was Fox. He didn't say why, but he did mention that he had access to details as moderater. I'm gonna go with his thought. SirChuckBThis country needs more Rutabegas 03:11, 12 November 2009 (UTC) Bot request (really lame)[edit] Can someone fix the links at [4] from punish to punish? Where is Radioactive Afikomen when we need him? ħuman 04:20, 11 November 2009 (UTC) - That's what redirects are for. -- Nx / talk 08:24, 11 November 2009 (UTC) - - Done, except for the link above and a list of redirects. Ta-da! Aboriginal Noise Punkrock 14:34, 11 November 2009 (UTC) Fetch the party poppers![edit] It's been a year and a day since I made my first edit; not the greatest, I must admit but I've changed since then. My deceptions are a lot harder to spot now. EddyP 21:05, 11 November 2009 (UTC) - hELL, even a bad excuse to party is better than no party at all. Tetronian you're clueless 22:18, 11 November 2009 (UTC) I give up.[edit] After years of resisting, I will finally give in and learn a programming languange. Two questions; - Which one/ones should I spring for at first? - Any good online resources for learning them? I'd rather not pay. Thanks. --The Emperor Kneel before Zod! 01:27, 10 November 2009 (UTC) - Welcome to the clan. I started with Java, which isn't too bad, but I think C is better to start with. Tetronian you're clueless 01:28, 10 November 2009 (UTC) - I recommend either COBOL or FORTRAN. SmartBASIC for the Coleco Adam is pretty good, too. Corry 01:32, 10 November 2009 (UTC) - PL/I has its place as well. - Though in all seriousness learn an object oriented language, probably C++ would be best. tmtoulouse 01:34, 10 November 2009 (UTC) - Learn C & work on from there. Many current languages have their roots in C so you should be able to pick & choose from there on. & marmitechat 01:36, 10 November 2009 (UTC) - Don't "spring" for one, use one that is open source. Basically unless you have a reason to learn a language you won't be able to. Computing languages are something you learn through necessity rather than sitting down and studying. First find a project you want to do and then work towards it. - π 01:37, 10 November 2009 (UTC) - @ Pi: I see your point, but I think TheemperorThedictator is asking because he wants to learn from enjoyment. There's nothing wrong with buying (or in my case borrowing) a textbook to learn purely for fun, and if you are a self-motivated person it is very easy. - @ Toast: Lol, I was beginning to worry that no one else would say C. (Although Trent does make a good point about C++.) Tetronian you're clueless 01:41, 10 November 2009 (UTC) - COBOL & FORTRAN are commercially oriented & scientifically oriented respectively -specialists only IMHO. As Pi says, without a reason to learn, you probably won't. Try Php or Javascript - you can use them on your website. (don't have anything to do with anything that includes "basic" in its name & avoid Microsoft like thye plague)& marmitechat 01:51, 10 November 2009 (UTC) - My dad was a COBOL programmer, last time anyone wanted him for that was during the Y2K compliance-update-thing. He hadn't programmed in it for about 20 years before that. - π 02:46, 10 November 2009 (UTC) - I was a COBOL programmer: professionally taught - finished course 2 weeks before being made redundant approx 30 years ago - never had anything to do with it since. & marmitechat 02:55, 10 November 2009 (UTC) - Ignoring my 14 year-old tinkering with BASIC, I've never been able to learn a computer language unless I needed to do something with it. Hence Perl, in my case (is that a real language? I dunno, it runs my websites) ħuman 02:29, 10 November 2009 (UTC) - There are some fine lines between "scripting languages" and "programming languages" but they are not really that important to this discussion. tmtoulouse 02:30, 10 November 2009 (UTC) - Pascal. Perfect language<not> to learn on, being too prudish to do any real work withso strongly typed that you will not fall into erroneous ways of coding. Sprocket J Cogswell 02:36, 10 November 2009 (UTC) - I you want thorough basic knowledge, start with C, then choose something else. If you just want to get programming, use Python. Elegantly written, strongly typed, excellent documentation. I would suggest to avoid Perl and PHP as I feel these are not really well constructed anymore (the cruft builds up), but that's highly subjective. Pascal is imho the best language ever designed, but it appears to be dwindling away nowadays. With Python you also have the spectacular advantage that you can try everything on the command line. Pietrow 08:21, 10 November 2009 (UTC) - BB: What are you learning programming for? If it's for a potential career change then learn C# or Java (unless you want to work in the gaming industry, in which case learn C++), or is it just for fun? If the latter then start with something easy like PHP and make yourself a practice website. The basics you'll pick up will be transferrable, but as someone else said, try and move to something OO. CrundyTalk nerdy to me 08:35, 10 November 2009 (UTC) - I agree with Sprocket. Start with Pascal - the original one by N. Wirth (?) - learn all the theory behind structured programming and become fascinated by it. You'll have time to learn more useful and practical languages afterwards. Also be sure to find a generic "computer programming" book for undergraduates (?), that explains the basics of programming and data structures without any particular programming language in mind. Not because you'll need all this knowledge, but because it makes the experience more rewarding. Editor at CPmały książe 09:37, 10 November 2009 (UTC) Not quite a threadjack, but kinda. I could use some programming/web development advice. I haven't touched programming since the 8-bit days. Basically I want to set up an online database, something fairly simple, for interrogating stored texts in plain text format. Any ideas on a good solution to use? It would need to be open source, and something reasonably easy to learn. Help pls! --TheEgyptian 10:09, 10 November 2009 (UTC) - I was being facetious when I suggested Pascal. It amounts to a toy language in my opinion. You may apply disciplined structural style just as well in C, and will still have the freedom to massage your data effectively. Forth seems like another good choice, but it takes discipline to keep from creating write-only code with it. Sprocket J Cogswell 14:19, 10 November 2009 (UTC) - I wasn't. It is that lack of freedom that makes it a superior language to C. And also because it was the language I studied at university not SOOO many years ago. Editor at CPmały książe 09:38, 11 November 2009 (UTC) - p.s. Showing my age, but has anyone done something better than Knuth's Art of Computer Programming? Some of the volumes that actually got written were pretty good, as I recall. Sprocket J Cogswell 14:24, 10 November 2009 (UTC) - C++ is the language to learn. After that, you'll be able to pick up lots of other languages (and know what's wrong with them). — Sincerely, Neveruse513 / Talk / Block 14:31, 10 November 2009 (UTC) - I don't see what everyone has against BASIC anyway. Sure, VB6 is pretty damn awful, but it did help a lot of companies out. And now with VB.NET you have a simple to learn language on top of an excellent framework, all topped off with the best IDE in the world. Personally I think anyone who wants to get into programming should mosey on over and get themselves a free copy of Visual C# Express, learn that, and then should you want to switch to C++ / Java, you'll find it an easy transition. Or, just get Visual Basic Express and learn that. It's the easiest way to learn as the tools are extremely user friendly. CrundyTalk nerdy to me 14:35, 10 November 2009 (UTC) - BASIC made for a good introduction to simple concepts of programming. But after that... — Sincerely, Neveruse513 / Talk / Block 14:38, 10 November 2009 (UTC) - EC)N I agree, but I have to stick up for VB.NET because the cool thing about .NET is that you can write it in any language you want (seriously, anything! You can get COBOL.NET and even Whitespace.NET) and it all gets compiled down into the same language anyway (MSIL). CrundyTalk nerdy to me 14:42, 10 November 2009 (UTC) - I learned basic first but had to unlearn almost everything later: it's undisciplined (or at least it was - not tried any of the later versions) I just put "programming C" (no quotes) into google & got 000s of hits. The first page at least seems to be almost all tutorial oriented. C gives a good grounding in discipline & C++ in Object Orientation. With either of these under your belt you should be able to take on anything IMHO. If you just want to script for the web then begin with Javascript → PHP. & marmitechat 14:43, 10 November 2009 (UTC) - A word: whatever you learn, get into the habit of commenting within your code: even the simplest of statements can appear opaque when you return to them a year or even a day later. & marmitechat 14:52, 10 November 2009 (UTC) - Agreed. There's nothing worse than going back to your code and saying to yourself "What the hell is this idiot doing here? Oh wait, that was me!". CrundyTalk nerdy to me 14:58, 10 November 2009 (UTC) - Good code documents itself. Also, java is a scam. Is it 80's? Rather slit your wrists than lose your innocency learning java. --194.197.235.240 22:15, 10 November 2009 (UTC) C is useful for low level system programming. I wouldn't recommend starting with that. I wouldn't recommend it for writing anything but low-level system stuff, yet there are people who disagree. Those people are obviously insane. C++ is powerful but most of the time you don't need that power and it just makes things more complicated and error-prone. Contrary to the uninformed opinions of some, Pascal is also a very powerful language, and overall it's my favorite. C# (which is in many ways closer to ObjectPascal than C/C++) is also nice, and programming in Visual Studio is so easy it's embarrassing. -- Nx / talk 14:59, 10 November 2009 (UTC) - The first thing I learned to program in was 8086 assembler under DOS. Using Debug. After that, pretty much anything else is a piece of cake. These days, I mostly use C# because Microsoft have already written so much code for you, you get to deal with the interesting stuff instead of worrying about how to implement a dictionary. –SuspectedReplicantretire me 15:09, 10 November 2009 (UTC) - Yeah, I've made a career out of pretending I can code with Visual Studio :) Seriously though the new LINQ functionality is fucking awesome. I wrote an entire database driven app without a single stored procedure (used LINQ-to-SQL instead) and I use straight link to cut down on the number of procs we have because I can join business object collections together into anonymous types. Behold: Me.gvwMissing.DataSource = From em In colMissing _ Group Join emp In colEmployees On em.EmployeeId Equals emp.EmployeeId _ Into eGroup = Group _ From e In eGroup.DefaultIfEmpty() _ Select New With {.EquipmentMissingId = em.EquipmentMissingId, _ .EmployeeName = If(e Is Nothing, "", e.Name), _ .EmployeeId = If(e Is Nothing, 0, e.EmployeeId), _ .QuantityMissing = em.QuantityMissing, _ .DateMissing = em.DateMissing} CrundyTalk nerdy to me 15:22, 10 November 2009 (UTC) - Oh, and P.S. TFS is freakin' incredible. Behold my gated checkin app which stopped all the dipshit contractors at my last place fucking up the build just before a code freeze! CrundyTalk nerdy to me 15:23, 10 November 2009 (UTC) I would advise Python. It's object-oriented, the syntax is logical and simplistic, it comes with an extensive and easy to use standard library, it's cross system, and a breeze to learn. Here's a sample: print "Hello world!" That prints, "Hello world!", this next example does a bit more by querying the Conservpedia API for information and prints it: import json import urllib2 req = urllib2.Request(' headers = {'User-Agent':'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'}) #The headers part keeps the server from flagging the program as a bot inf = urllib2.urlopen(req) jso = json.loads(inf.read()) for key in jso: val = jso[key] strg = key + ' = ' + val print strg So Python is really easy to use, try it at --Ipatrol 22:13, 10 November 2009 (UTC) - I'm not exactly sure why, but I'm almost positive that significant whitespace is the devil. — Sincerely, Neveruse513 / Talk / Block 22:18, 10 November 2009 (UTC) - I started reading this thread thinking - hey this could be interesting. Which language would be bes to learn? HA! Every opinion is different! I'm more confused than when I started. - Being serious, I would probably go with Python. Stupid evil Phantom! 22:38, 10 November 2009 (UTC) - In all seriousness, I think Python is a horrible language to learn first. Stick with something more like a programming language and less like pseudocode. BASIC or C++. Then come your perls and pythons. — Sincerely, Neveruse513 / Talk / Block 22:57, 10 November 2009 (UTC) Below is a semiproper browser in python. Just to show gnome's actually sanity. Also to tell you that java is a pile of bullshit. I laugh at any java trying to match this with anywhere near the same portability. #!/usr/bin/python import gobject import gtk import webkit gobject.threads_init() window = gtk.Window(gtk.WINDOW_TOPLEVEL) scrolled = gtk.ScrolledWindow(None) scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) webview = webkit.WebView() frame = webview.get_main_frame() frame.load_uri(' scrolled.add(webview) window.add(scrolled) window.connect('delete-event', gtk.main_quit) window.show_all() gtk.main() --194.197.235.240 23:16, 10 November 2009 (UTC) - Meh, I really don't want to get back into IT, just know enough to get on with my projects. VB Express looks pretty well suited to my needs, provided it works well for web deployment. I'm so damn out of date with computers. --TheEgyptian 00:15, 11 November 2009 (UTC) (undent) My two cents starts with a pair of questions - why do you want to learn to program, and what do you plan on applying that new skill towards? If you are looking to get a job based on programming, think about the kinds of settings you want to work in and the needs those employers have. For example, if I wanted to work for a bank or brokerage house then a language like C, C++ or java would be appropriate, as would scripting languages like Python or Perl. In other settings SQL and XQUERY might be more in demand, and if you're into web design then HTTP, AJAX or Flash would be good. Focus on what you want to do, and a little inquiry into the tools used there will guide you. If you're just looking to tinker, try BASIC, Visual Basic or Perl. I'd also look at sites like w3schools, which offer great free online tutorials that give you a sense of various languages. Good luck, and have fun. --SpinyNorman 21:24, 12 November 2009 (UTC) On the death penalty and being a bleeding heart liberal[edit] - This discussion was moved to Debate:On the death penalty and being a bleeding heart liberal.21:31, 12 November 2009 (UTC) Remembrance Day[edit] There is a moving slideshow on the BBC website with commentary from those who fought in World War I. ГенгисRationalWiki GOLD member 10:35, 11 November 2009 (UTDB 12:25, 11 November 2009 (UTC) "Pack up your troubles in your old kit bag..." Such a lovely song with such a sad meaning. Peace. SJ Debaser 13:56, 11 November 2009 (UTC) - Arthur Guy Empey's "Over the Top" was written by someone who was there. I think that's where I read the bit about the company mascot sucking in his frothy green last breath with his paws over his nose, as low to the ground as he could get, without a doggy gas mask. Forgive me if I've applied some creative mis-memory and artistic license there. Once heard an elder male relative, a career artilleryman, say, "War is a wasteful process." - My own meager experience is consistent with that observation. Sprocket J Cogswell 14:33, 11 November 2009 (UTC) - I would like to add my utmost respect for those who put their lives on the line in the defense of what they hope was the right cause. As a pacifist, I would never risk what they have, but I respect that, over time, many of them have made it possible for me to hold my position. I thank you, my fallen friends. ħuman 06:39, 12 November 2009 (UTC) - I'm a great fan of comic strips, and I always appreciated the Charles Schulz would commemorate Veteran's Day and D-Day in Peanuts. - There's also a User Friendly strip I appreciate enough I keep a print out of it on my office door. I can't get through to the strip's archives now, so I'll describe it - Panel 1: One of the characters is at his computer: Man, I do love these World War II shoot-em-up games. One more try at taking that hill and... - Panel 2: He looks up, sees the date is November 11 - Panel 3: The computer stands alone, with a poppy next to it. MDB 16:38, 12 November 2009 (UTC) protecting high use templates[edit] I think we should protect high usage templates. If a template is edited, all pages that use it have to be reparsed, which puts a lot of load on the server. I've already protected Template:! after some vandalism yesterday (see the talk page), and now I've created Template:Doc to move the documentation out into a subpage so it is still editable. I've added this new doc template to the top 30 templates, although some of them don't have a documentation subpage. These are here (wait a bit for the category to fill up, all this editing I've done is slowing things down), and you're welcome to write some. If you click the create link on the template page, it will preload the basic structure. -- Nx / talk 12:13, 11 November 2009 (UTC) - Very good idea. Arguably, all templates should have at least semi-protection. Why would a BoN want to edit one of our templates? –SuspectedReplicantretire me 12:35, 11 November 2009 (UTC) - In some cases such as Template:= there's no need for anyone to edit it (now that the documentation is on a separate page), but with others that's not so clear. Why shouldn't a BON be allowed to add a random verb to Template:Verb, for example? I can give you an example of me editing a template before I was a sysop (and before I had the number of edits required for autoconfirm). -- Nx / talk 12:53, 11 November 2009 (UTC) - It's a trade-off. Which is of more help to the site: users not being able to edit a template for a few days until they make their edits, or stopping server-hitting changes to templates by spam/nonsense bots? Fair enough about Template:Verb, but what about ones like Template:Welcome or Template:Unsigned? In general, I don't think there's any need for new users to be editing those. Having said that, I'm not going to get dogmatic about it. Most things on RW are left open on principle so I wouldn't oppose keeping them unprotected. –SuspectedReplicantretire me 13:03, 11 November 2009 (UTC) - Yes, I agree with that. What I'm saying is that only those templates that are used a lot should be protected, not all of them (and semi-protection is not very useful because people generally become sysops before they reach autoconfirmed status nowadays.) -- Nx / talk 13:11, 11 November 2009 (UTC) - Well, if RW expands and its reach increases then the amount of vandals that it will attract will increase. People with relatively minor technical knowledge know what to edit to cause havoc, there may even be bots out there just going to random websites and trying it out. Basically, the whole thing about the wiki being totally open was fine when it was small and unnoticed but it's getting to the point where we need to more seriously consider those policies in the face of the wiki growing larger - and by this I don't mean putting it to a vote, I mean having the guys with server access and expert knowledge figuring out what could go wrong, how to fix it and just doing it. So basically, if a wayward edit could cause severe hassle (like bigdelete, which I think you've already removed from normal sysopship) it should be prevented - there's no reason to edit these, and any edits to well established templates or settings should be discussed first anyway. postate 13:34, 11 November 2009 (UTC) I'm going to speak out against the protection of high-use templates. High-use templates are a potential target for some very funny vandalism. Reverting unfunny vandalism to high-use templates is no more difficult than reverting vandalism to lesser-important pages. — Sincerely, Neveruse513 / Talk / Block 21:13, 11 November 2009 (UTC) - - I vote yes to protecting high use templates, but not to the sysop level. Making them protected for the "User" level is good enough, in my opinion, as the attacks, as of late, have been by anonymous IP vandals. Gooniepunk2010 Oi! Oi! Oi! 21:15, 11 November 2009 (UTC) - I agree, though we can only protect at the autoconfirmed level, so it won't make much of a difference most of the time. -- Nx / talk 08:15, 12 November 2009 (UTC) - I've just done the top 12 as after that (Template:Unsigned) the number of places linking to them start dropping more dramatically. postate 14:03, 12 November 2009 (UTC) - Pages are only reparsed when they're requested, right? It seems to me this is a work around for a really trivially technical fix. That is to record for each page marked dirty the revision ID of the edit that made it dirty. Then when an edit is reverted, you can perform two separate database updates. One which marks all pages including this page as dirty where the page is not currently dirty or the revision ID of the edit which made it dirty does not match the edit we are reverting. The second query marks pages as clean where the page is currently dirty and the revision ID of the edit that made it dirty matches the edit we are reverting. Wouldn't that solve the problem? --JeevesMkII The gentleman's gentleman at the other site 17:50, 12 November 2009 (UTC) - They have to be reparsed even when not requested to update category and linking information (and maybe more). Apparently MediaWiki is smart enough to detect that the doc subpage is included in the noinclude section, so it doesn't trigger an update for every page the main template is included in. - I don't think your solution is so trivial, but in any case this would be a better place to suggest it. -- Nx / talk 09:10, 13 November 2009 (UTC) Does anyone else think Kent Hovind is funny?[edit] I don't even mean in an unintentional way. When I listen to his bullshit, I honestly start chuckling sometimes because I think he has a good sense of irony, and knows how to structure a joke. If he were a stand-up comedian instead of a creationist, I really think he'd be incredibly good, and I'd love to watch him. Does anyone agree? --Mustex 23:23, 11 November 2009 (UTC) - Nah, I think his "good sense of irony" is actually a bad sense of irony, as his intention is not to be funny. As for knowing how to structure a joke, I think that is another example of his bad judgement, as his arguments are supposed to be persuasive. Tetronian you're clueless 01:23, 12 November 2009 (UTC) - I agree. He is very charismatic, well-spoken and has nice delivery. — Sincerely, Neveruse513 / Talk / Block 15:09, 12 November 2009 (UTC) - No, he isn't at all funny. His jokes are terrible. And often extremely mean. Example: San Francisco: the land of the fruits and flakes. That's his idea of humour. And worse, the audience yuk it up. Twats. I will say he's funny in a schadenfreude kind of way now he's in jail. --JeevesMkII The gentleman's gentleman at the other site 16:36, 12 November 2009 (UTC) Get out of my head, RW![edit] As much as I love RW, it is definitely influencing me a hell of a lot more than I thought it would. In my World History class yesterday we were discussing Europe and Christianity in the 500-1500 BCE time period, i.e. when Europeans began to study Greek philosophy again and eventually created rationalism. So we were talking about that and I found myself launching into a long and rambling rant about the rationalist viewpoint, complete with snarky attacks on dogmatism, fundamentalism, and creationism. Somehow I ended up talking about creation science, Hovind, and ID. At that point I realized that everyone was looking at me with that "What the fuck?" kinda look. It was pretty weird. Tetronian you're clueless 14:25, 12 November 2009 (UTC) - You need to make sure you keep calm when ranting, otherwise you're always in danger of running off-topic and making no sense. Perhaps you just went off on Gish Gallop without realising. postate 14:28, 12 November 2009 (UTC) - I'm pretty sure I did. Which is sad, because I am on a debate team and am one of the best in the state. I guess I got a bit worked up about the topic, so I went on a rant. Tetronian you're clueless 14:30, 12 November 2009 (UTC) - One of the best in the state??? One of the best in the state?? Only an American would make such a shamelessly absurd and self obsessed comment. Wanker. MarcusCicero 22:52, 12 November 2009 (UTC) - "Europe and Christianity 500-1500" - so a pretty narrow topic then! Bob Soles 14:34, 12 November 2009 (UTC) - Well we started off talking about Byzantium and the public works projects created by the Emperor Justinian (especially libraries), and that led to a discussion of the re-translating of Greek philosophical works. Tetronian you're clueless 14:46, 12 November 2009 (UTC) - Hey, it could have been worse. You might have accidentally parroted one of the Assfly's world history "insights" and got yourself a failing grade. --JeevesMkII The gentleman's gentleman at the other site 16:43, 12 November 2009 (UTC) Matt Bors[edit] I know it pales in comparison to Karajous mini masterpiece, but Matt Bors one of my favorite artists, had a great one up yesterday. SirChuckBThis country needs more Rutabegas 19:13, 12 November 2009 (UTC) In case anyone followed this story a while back...[edit] A 13-year-old boy in Minnesota gained national attention a while back when he stopped leukemia treatment after one session in February and fled, citing his religious beliefs. . This fired up the crowd who felt that big government was telling this family what to do despite their beliefs, and some even saw it as an attack on faith-based healing. Doctors said that non-treatment would be a death sentence, and eventually the boy and his mom returned and agreed to conventional treatments. I'm glad to report that he's been declared cancer-free following his final chemo treatment. I feel bad that he was sick in the first place, that he wound up in the media spotlight, and because chemo's certainly an ordeal in itself. This story just frames the anti-vaccine hysteria, and why it's okay to question if a new vaccine is safe, but to not fear and avoid them irrationally either. --SpinyNorman 21:44, 12 November 2009 (UTC) Another reason I'm no longer a practicing Catholic...[edit] Because this makes a lot more sense than spending $10K feeding the hungry or sheltering the homeless... --SpinyNorman 21:58, 12 November 2009 (UTC) - In a business sense, I suppose it was a wise investment and churches are businesses, after all. — Sincerely, Neveruse513 / Talk / Block 22:10, 12 November 2009 (UTC) I think that's all you really need to know. postate 09:25, 13 November 2009 (UTC) Nice to see climate changes is not occurring[edit] Seeing as the mild summer in New Jersey has conclusively disproven the effects of global warming, I have to chalk this up to one of those things. In March Tasmania had its first ever heat wave and we have had another first. Where I live back on the mainland, we have had our first ever heatwave in November - it is still spring and we are having heat wave. Five day so far above 35C (95F) and the next three are going to be 40C (104F). I am just bitching because it is hot. - π 22:16, 12 November 2009 (UTC) - It's fucking freezing, windy and constantly pissing it down here. My heart bleeds for you. CrundyTalk nerdy to me 08:52, 13 November 2009 (UTC) Fundies, Fundies everywhere, and not a brain to think[edit] So I'm listening to a radio talk show, where they're interviewing the guy who lead the team that discovered our newest dinosaur (no, not Winnie Mandela, Aardonyx celestae) and they open the lines for callers. Within the first couple we get a Gish Gallop "Evolution is a lie! Earth is only 6,000 years old. You're wrong to say it's 170 million years old! The Flood killed the dinosaurs! Why don't you open your mind?" The last bit had me thinking Andy had phoned in. Response in studio - quiet chuckles. --PsygremlinSprich! 18:19, 13 November 2009 (UTC) - Do you remember the 80s teen-angst movie Heathers with Christian Slater and Winona Ryder? The principal in the movie dismisses a touchy-feely comment by the guidance counselor with the sentence: "You'll let us know when the shuttle lands." I have no idea what that means in that context, but it just sounds damn dismissive. Either way, that is the first thought that goes through my head when I hear things like that. --Edgerunner76Your views are intriguing to me and I wish to subscribe to your newsletter 18:31, 13 November 2009 (UTC) "Do as we say, not as we do", Part XXXVIII...[edit] Why was I not surprised to see that the GOP's own healthcare plan provides coverage for elective abortions, and has been doing so since around 1991. Apparently they passed up several chances over the years to opt out of that coverage, until it was pointed out to Michael Steele, who's moving quickly to make the issue go away. After making sure this coverage was pulled from the House healthcare reform bill, it would be a little awkward going through the Senate vote with that bit of hypocrisy hanging over their heads. What I'd love to know is if there's any way the GOP could be pressured into reporting on how many elective abortions were covered under their plan since 1991 - reporting the total count would not be a violation of anyone's privacy. --SpinyNorman 20:09, 13 November 2009 (UTC) - Such pressure would be counter-productive. It would be very easy for them to respond with a simple lie, saying that no abortions were ever paid for by the plan. And in fact, that might well be true.--Tom Moorefiat justitia 20:42, 13 November 2009 (UTC) - Also, it's worth noting that the number of female staffers has probably been miniscule, so it's not exactly going to preserve their privacy if the GOP were to release stats.--Tom Moorefiat justitia 20:44, 13 November 2009 (UTC) So hi[edit] Maybe it's silly, maybe it's unwise, but I've had a couple of glasses of wine, and my ears were burning, so I signed up for an account here. Hi. Now you can talk about me in front of my back. Or possibly standing over my snoring, drooling, unflatteringly unconscious body, depending on whether or not I decide to finish this bottle. --4perf 01:37, 14 November 2009 (UTC) - Heh, no problem, although it's usually best on this page to just edit one section, or use the "new section" link. Anyway, about that wine, does it go well with mushrooms? ħuman 01:54, 14 November 2009 (UTC) - Oops. I'm new at this whole wiki thing. Hey, what's this button for? Oh crap. Undo! Undo! --4perf 02:02, 14 November 2009 (UTC) - That seemed to work perfectly! ħuman 03:53, 14 November 2009 (UTC) - You fool! Never edit the interwebs when pissed. Bad things happen. CrundyTalk nerdy to me 20:49, 14 November 2009 (UTC) Onion: Portrait of a teabagger/birther[edit] This worries me. When the Onion is starting to run truthful news stories, I think it might be time to re-stock the fallout/y2k/2012 shelter. -- CodyH 17:43, 14 November 2009 (UTC) - That's the thing about satire; it doesn't have to be wrong, or even funny. It just has to take things almost literally and show them up as absurd. postate 17:52, 14 November 2009 (UTC) Dr. George J Georgiou, Ph.D.,N.D.,DSc (AM).,MSc.,BSc[edit] I occasionally get spam from this remtard, and so I thought I'd share it with you lot before reporting it to spamcop. Dear friends and colleagues, You have not heard from me for quite a while now as I have been quite busy researching and writing my latest book entitled “Curing the Incurable with Holistic Medicine.” As you are all supporters of natural or holistic medicine, you are probably aware that many of the allopathic doctors tend to look down on many healing modalities that use natural methods of treating. Their argument is that it is not scientific or “evidence-based.” I therefore took on the task of writing this 610-page book on many aspects of holistic medicine with over 800 scientific references to prove that holistic medicine is as much “evidence-based” and scientific as allopathic medicine - this has been two years in the making. Please feel free to read some sample chapters as well as read all the 15 case histories of “incurable” cases treated using the holistic medicine model at the DaVinci Holistic Health Centre in Larnaca, by visiting or The book has just been released and is available for sale on amazon.com and other major online bookshops. I will be back shortly to share with you some other interesting topics that I have been researching. Best regards, Dr. George J. Georgiou, Ph.D.,N.D.,DSc (AM).,MSc.,BSc Holistic Medicine Practitioner / admin@docgeorge.com Tel: 24-82 33 22 Fax: 24 -82 33 21 A book? Oh fuck, we're all doomed!! CrundyTalk nerdy to me 20:46, 14 November 2009 (UTC) - I took the liberty of adding a couple of redlinks to the spamtext in hopes of inspiring some creative writing here. ħuman 21:58, 14 November 2009 (UTC) - Reading his diplma mill line, all I can think of is "Richard Lenski signed his letter as Richard Lenski" postate 20:10, 15 November 2009 (UTC) - Human: I made one of the links unred. Hope it's up to your standards. --Irrational Atheist 01:34, 16 November 2009 (UTC) He lists his bachelor's and master's? Why would he do that? Also, why did he list his doctoral degree twice... or does he have two? And I will admit I had to look up "N.D." (Doctor of Naturopathic Medicine). SUSPICION.--Tom Moorefiat justitia 08:25, 16 November 2009 (UTC) Ah, I see his doctoral degrees are different, although not equivalent (DSc in other countries apparently being equivalent to an LLC or the like.--Tom Moorefiat justitia 08:27, 16 November 2009 (UTC) - It seems none of his qualifications included any kind of mention of internet mailing etiquette. Considering he's spamming people who haven't opted in to his mailings in any form, there is no unsubscribe link in his emails, and he thus far has not responded to two of my replies to have my address removed from his mailing list. CrundyTalk nerdy to me 11:05, 16 November 2009 (UTC) Did I make a good point?[edit] I'd like opinions: --Mustex 18:27, 15 November 2009 (UTC) - Well, I think it's a good point, but not "very" well made, IMO. The editing when you introduce the main points (who can breed with who) makes them a bit rushed and unclear. If I didn't know what you were explaining, I wouldn't have been able to follow it. ħuman 19:49, 15 November 2009 (UTC) - Yeah, xtranormal tends to do that. I don't have a webcam, so I'm as much hoping to inspire others to make videos on this subject as hoping to convince anyone personally.--Mustex 19:57, 15 November 2009 (UTC) - Ring species are a good argument for evolution but, as the editor above mentions, unless you've already got a good grasp of the issues then you won't understand the video. And if you've got a sufficiently good grasp of the issue then you don't need the video. I didn't even notice you giving a simple introductory definition of ring species. Incidentally, we have many ring species on Jupiter. They live on our rings.--Skynet 21:08, 15 November 2009 (UTC) - Suggestion - redo it by first writing a clear script (defining ring species as our jovial friend suggests) and instead of the goofy animatron narrating, use images that clarify what you are saying. They don't need to move, just to be easy to understand. If you want to experiment with those two steps in a sandbox here on the wiki that would be cool, I'd be glad to try to help, at least offering suggestions. ħuman 23:05, 15 November 2009 (UTC) There's never a bad time to link to Icanhascheezburger[edit] Hippy goat! Totnesmartin 23:51, 15 November 2009 (UTC) - Ahahahaha! That's great, thanks for posting. Tetronian you're clueless 02:17, 16 November 2009 (UTC) anybody want to play?[edit] Took some mushrooms. Your move. — Unsigned, by: Neveruse / talk / contribs thanks buddy. Wish you were here. For cereal, I'm off my fuggin rocker so have fun with it. - Qxg7# --The Emperor Kneel before Zod! 02:45, 14 November 2009 (UTC) - I fucking LOVE magic mushrooms. Love'emLove'emLove'emLove'emLove'emLove'emLove'emLove'emLove'em. Enjoy. Go ask Alice, when she's ten feet tall. TheoryOfPractice Thanks TOP. Ate another couple grams for you. - your changes will be visible immediately. - Some changes take time to appear, others appear before the time they are expected.... - can't find the tilde on my blackberry. Mop on. - Can't you just copypasta or press the magic signature button. - I'll take a threesome over mushrooms, alcohol, or any "drugs"... any day Udon 04:08, 14 November 2009 (UTC) - You and two hot young boys in tights? - Now a threesome on mushrooms... if you can stop giggling for long enough, of course. Hope you had awesome music to go with them. --PsygremlinSpeak! 05:35, 14 November 2009 (UTC) As Lucy hit the sky and all kinds of apple pie...? SJ Debaser 16:44, 14 November 2009 (UTC) - What kind did you take? I took some "philosopher's stones" back when they were still legal in the UK, but none since. CrundyTalk nerdy to me 20:50, 14 November 2009 (UTC) - You people make my life seem so boring, mundane and suburban. The highlight of my weekend was a community theatre production of Little Shop of Horrors. MDB 13:50, 16 November 2009 (UTC) - Buy some acid off some of the kids hanging around outside. CrundyTalk nerdy to me 14:01, 16 November 2009 (UTC) - I doubt I'd have the nerve to take acid. Though if I did, the place I saw the play (Greenbelt, MD) would be a good place to find some, I'd imagine. It, along with Takoma Park, is one of most "hippie" towns in Maryland. MDB 14:18, 16 November 2009 (UTC) - MDB, the highlight of my weekend was finding out my ex-girlfriend has found someone new, and me spending Friday and Saturday night alone getting shitfaced and smoked out of existence - I'm a STUDENT and that was my weekend! SJ Debaser 18:49, 16 November 2009 (UTC) - @Josh: That sucks. Be strong big man, plenty more sperm-recepticles in the world and all that. @MDB: Acid isn't as bad as people make out. Anyone who tells you an acid horror story involving demons or fruit (e.g. I thought I was a banana and tried to peel myself) has never taken acid in their lives. To get that kind of trip you'd have to take an A4 sheet. The best thing is to titrate your gear; take half of your tab, wait an hour and assess how fucked you are, and then take the other half if you are still coherent. Works for me. Mainly you'll just find yourself staring at the carpet and giggling rather than screaming about dragons and the floor eating you. CrundyTalk nerdy to me 23:13, 16 November 2009 (UTC) - HA! Cheers Crundy. I'm OK and pretty much over her, we've been split up for nearly 6 months now anyway. I just found out via Facebook "Such-and-such is now in a relationship!" in the middle of my radio show. As we're on the topic of drugs, I just finished watching Fear and Loathing in Las Vegas and man was that one weird fucking film. Pretty funny though. SJ Debaser 00:50, 17 November 2009 (UTC) - Awesome film, but not to be copied. Anyway, fuck her, go storm the fresher's parties. You would not believe how up for it first year nursing students are. Getting laid at uni is like walking through a forest at night. Sooner or later you'll hit a tree. CrundyTalk nerdy to me 00:54, 17 November 2009 (UTC) - Not be copied? Why not? I have come close but never to the same degree but that was due to lack of funds as opposed to fearing for my health and sanity. AceMcWicked 00:57, 17 November 2009 (UTC) - Indeedio, that's what I've been doing! I can easily imagine Ace running around like a mad eejit, pimping fifteen year-olds and having a ciggy dangling out his mouth for every second of the filmhis life. SJ Debaser 01:00, 17 November 2009 (UTC) - I have got a three day long party to attend this weekend up on the coast. Things are bound to get weird. AceMcWicked 01:06, 17 November 2009 (UTC) - I'll be the one with a .44 Magnum and a handful of pills in an Hermes briefcase. 01:10, 17 November 2009 (UTC) - Ace, check back in with us when it's over so we know that you're alive and well, and that after a day your eyes didn't start to bleed for whatever bizarre reason. I'm going back home this Friday for a friend's party, and OH we're going out on the town and I am going to regret it the morning after. SJ Debaser 01:37, 17 November 2009 (UTC) Dembski's vague wackings off[edit] He is threatening us with a law suitimg, do we ignore him or laugh? - π 02:46, 16 November 2009 (UTC) - We laugh. Until his lawyer figures out how to contact us, at which point we should probably check with someone who is 100% certain of the law before we keep laughing.-- Antifly Merged with Infinity 02:55, 16 November 2009 (UTC) - Both. He's an idiot, and might actually finally make us notable to WP! Quoting in full context is the utmost level of respect for sources. Would he prefer we quote-mine him? ħuman 02:57, 16 November 2009 (UTC) - Actual as the IEEE is the copy-right holder (he signed it over when he submitted the paper) we should check he is not violating the copy-right by putting it up on his website. - π 03:15, 16 November 2009 (UTC) - - That's a good point. Although if he is violating it, doesn't that mean we are too? Tetronian you're clueless 03:23, 16 November 2009 (UTC) - Ohhhhh interesting. AceMcWicked 03:27, 16 November 2009 (UTC) - I would say that we are using it for criticism of the subject material, which means we would be protected by fair use. So yes, but... - π 03:29, 16 November 2009 (UTC) - But what? Tetronian you're clueless 03:36, 16 November 2009 (UTC) - No buts, we are in the right here. ħuman 04:25, 16 November 2009 (UTC) - The but was, but it is permissible in some circumstance to violate copy-right, which we are probably covered by. - π 04:29, 16 November 2009 (UTC) - Note that for many journals it is understood that authors will include preprints or drafts on their websites even if the journal has the copyright. This means that Bill is *techincally* violating copyright but in a way that everyone takes for granted is acceptable (some journals even explicitly give permission. These things are complicated). Now, it likely means that the journal, not Dembski is the holder and so they would need to make the relevant legal actions. However, if this is based on an early draft it is possible that Dembski retains some copyright rights. I don't know. I'm not a lawyer and these things are complicated. However, there's almost certainly a fair use claim here given the critical commentary that makes this completely acceptable on RationalWiki's part regardless of who owns the copyright. JoshuaZ 04:43, 17 November 2009 (UTC) - Let us see what exactly Bill decides to do, and what the situation with the copyright actually is. In the mean time I think it is safe to say that article will be getting some attention, let us make it as good as we can. tmtoulouse 05:45, 16 November 2009 (UTC) - Wow, what a tempest in a teapot! BTW, the IEEE (probably) is not the copyright holder of the article in question: W. Dembski only announced that it is to be published in a peer-reviewed journal, but didn't say in which... The previous article - which I excerpted to a lesser degree - was published in an IEEE journal. - The excerpts of "The search for a search" were taken from a draft, published on R. Marks site, and linked-to by the evolutionary informatics lab. It is not longer available on these sites. - Sorry, I didn't want to be the cause of trouble, I think that there is nothing wrong with my deconstruction of his article. We could drop the uncommented section 1, though. - larronsicut fur in nocte 07:11, 16 November 2009 (UTC) - Nah, nah, nah, we like trouble. Thank you! Lets hold tight for now. Make improvements if you think they will help but don't do anything yet because of the threat. tmtoulouse 07:14, 16 November 2009 (UTC) - Thank you - I'm glad to have written the article here on RationalWiki! BTW, I tried to comment on UncommonDescent: Dear Dr. Dembski, the easiest way to get the article taken down would be to show how embarrassingly wrong the critique is. - But alas, comments are closed now... larronsicut fur in nocte 07:33, 16 November 2009 (UTC) - Also remember what we learnt from Schlafly when he tried this trick. Even if he sends a formal letter, we don't pull it down. We usual have a statutory time in which to formulate a response. - π 08:05, 16 November 2009 (UTC) - Don't you have anti-SLAPP laws in canukistan? CrundyTalk nerdy to me 09:18, 16 November 2009 (UTC) - On WPability - it pleases my post-CP heart that we could pass Wikipedia's notability rules for a non-CP event. Totnesmartin 10:12, 16 November 2009 (UTC) I added a few lines to wp:William A. Dembski#WEASEL controversy, though I'm obviously not the best choice to do so... larronsicut fur in nocte 10:36, 16 November 2009 (UTC) - Deleted as not-noteworthy. CrundyTalk nerdy to me 12:04, 16 November 2009 (UTC) - "Yes Mr Dembski, I can assure you and your colleagues that we will remove the content as soon as possible. OK, thanks and goodbye" (leans into microphone) "Kill Them!". CrundyTalk nerdy to me 10:59, 16 November 2009 (UTC) - The only reason he could have to request a take-down is that he's unhappy with being critiqued at all. If we did the same with, say, Richard Lenski's paper, I'm sure Lenski wouldn't have an issue (and doesn't Conservapedia have a side-by-side of that one?). So, what's the best that can happen from Demski's point of view? The original gets removed but LArron's half stays and we just link to a source and selectively quote (mine), a take down order can't remove the annotations at all so let him bark all he wants, he doesn't have much to stand on with respect to removing what he really disagrees with. Or, we can request that he does the more noble and certainly more scientific thing and actively responds rather than shouts about infringement. postate 13:28, 16 November 2009 (UTC) - The number of views for the article doubled since yesterday (~840 today, 430 yesterday) , so it's a minor Streisand effect. larronsicut fur in nocte 16:46, 16 November 2009 (UTC) Hi Ames[edit] - π 22:35, 16 November 2009 (UTC) New Scientist on Swine Flu myths[edit] For those who might be wondering about vaccination, this NS article is interesting.--BobNot Jim 11:29, 16 November 2009 (UTC) - The comments on that site are full of the stupid. People go nuts when you mention vaccines. CrundyTalk nerdy to me 11:58, 16 November 2009 (UTC) - Yes, the article is very good but the comments make you despair for the human race.--BobNot Jim 12:04, 16 November 2009 (UTC) - The anti-vaccination people drive me up a wall. Smallpox has been eradicated. The only known smallpox virii exist as laboratory samples, and the scientific community debates whether those should be destroyed (what if we do need to sutdy it again vs what if it escapes/someone with evil intent gets a hold of it). Polio isn't quite that gone, but its close. And both of those occurred because of vaccinations. But yet, you get these morons running around like headless chickens, fearful of things they just don't understand. It pisses me off royally. MDB 12:51, 16 November 2009 (UTC) - Wow. After reading the comments I feel so much stupider. Tetronian you're clueless 12:59, 16 November 2009 (UTC) - Yep, the comments fail to disappoint from the very beginning... postate 13:16, 16 November 2009 (UTC) - Apologies for sounding a bit sexist, but why are the majority / the nuttiest of the antivax comments made by women? Are women more succeptable to bullshit? CrundyTalk nerdy to me 13:29, 16 November 2009 (UTC) - There have been one or two theories/observations to that effect but I'm not 100% sure the effect is there or significant. postate 13:41, 16 November 2009 (UTC) - I'm just speculating, but perhaps because women as less likely to have studied science than men? (This isn't to say that women can't or shouldn't study science, just that more men study science than women.) MDB 13:47, 16 November 2009 (UTC) - That's the sort of reasoning that gets brought up when the question is asked. However, I'm not sure if there are actually any studies showing the prevalence of irrationality - just theories as to why it would be and a few anecdotes. So until we figure out if the effect is real (if someone knows, please let me know, this has been bugging me for ages), remember this phrase, supposedly attributed to Frederick Beiser: "Facts without theory is trivia. Theory without facts is bullshit." postate 14:21, 16 November 2009 (UTC) - Keep in mind the area we are in. Anti-vax woo is all about "for the children" a line of reasoning that is probably more likely to resonate with women than men. Other areas of irrationality are clearly dominated by men, for an extreme, look at tax protesters. tmtoulouse 15:38, 16 November 2009 (UTC) - I agree with Trent. There is definitely a psychology to irrationality, and certain things appeal to certain groups. Tetronian you're clueless 15:55, 16 November 2009 (UTC) Cover feature of this month's Wired is about Paul Offit and the Anti-Vax movement. 16:47, 16 November 2009 (UTC) - It's a nice feature. I can never shake off the "unholy crap" reaction I get from seeing the reactions Offit got from the Antivax crowd though. Some of the anecdotes from the Autism One conference are absolutely unbelievable (to my unjaded eyes.) I am too easily frightened though... Frummidge 16:58, 16 November 2009 (UTC) Isaac Asimov[edit] I just read this and since it is (a) about religion/logic and (b) full of win, I figured it was worthy of putting here. See also this one, which is amusing as well. Tetronian you're clueless 17:49, 16 November 2009 (UTC) - I think more Americans should read his short story "Life Without Fuel"--Thanatos 02:01, 17 November 2009 (UTC) 6th sense[edit] Am I a bad person for thinking that the kid's mum is seriously fuckable in that movie? I'd make her see dead people... Wait, that didn't sound as cool as I thought. CrundyTalk nerdy to me 23:30, 16 November 2009 (UTC) - Since when does thinking people are hot make you a bad person? And no, that did not sound cool at all. A little creepy actually. Tetronian you're clueless 23:34, 16 November 2009 (UTC) - YEAAAH, I'd love to strangle her... is it bad that that's the first place I go to? CrundyTalk nerdy to me 23:39, 16 November 2009 (UTC) - P.S. Fuck's sake, editing when pissed on homebrew is a massive massive chore. CrundyTalk nerdy to me 23:39, 16 November 2009 (UTC) - It isn't either "good" or "bad," it depends if you are into that sort of thing. BTW, what kind of wine do you make? Tetronian you're clueless 23:43, 16 November 2009 (UTC) - This, but with chopped and boiled dried apricots and lalvin D47 yeast, left on the (non-gross) lees for a few weeks. Fucking incredible. Fuck, I forgot how awesome this movie is. Now I'm scared I'm going to have stay up all night watching it with a gallon of wine in the fridge. CrundyTalk nerdy to me 23:46, 16 November 2009 (UTC) - You make it sound like a bad thing. I wish that's how I could waste an evening. Tetronian you're clueless 23:49, 16 November 2009 (UTC) - "Stuttering Stanley, Stuttering Stanley, Stuttering Stanley, Stuttering Stanley, STUTTERING STANLEY!!!!!" CrundyTalk nerdy to me 23:50, 16 November 2009 (UTC) - Damn it, now I really want to watch that again. BTW, have you ever seen this? Bruce Willis's best film IMHO. Tetronian you're clueless 23:53, 16 November 2009 (UTC) - That movie is also full of win, however, it was massively spoilt for me, having had to view it at the cinema on release with a group of school friends, including a German fucknut who I had to sit next to, who insisted on asking me what was going on every two minutes., Visualise the movie, then imagine having to explain it every two minutes. You dig, blood? CrundyTalk nerdy to me 23:57, 16 November 2009 (UTC) - That's a damn shame. Although I recommend seeing it again if possible, it was greatly improved the second time. Tetronian you're clueless 23:58, 16 November 2009 (UTC) - Seen it many times, and loving it. As an aside, that was the first movie that let me know that Brad Pitt is one of my most favorite actors ever, along with Johnny Depp. Two absolute masters of delving into the very soul of the person you are portraying. CrundyTalk nerdy to me 00:00, 17 November 2009 (UTC) - P.S. Fight Club. 'nuff said. CrundyTalk nerdy to me 00:00, 17 November 2009 (UTC) - 'Nuff said is right. That movie will never, ever, ever stop being awesome. Tetronian you're clueless 00:02, 17 November 2009 (UTC) - Wait, I think we're breaking the first two rules. CrundyTalk nerdy to me 00:04, 17 November 2009 (UTC) - Shit, you're right. Now AceTyler will hunt us down and beat us up. Tetronian you're clueless 00:07, 17 November 2009 (UTC) (UI) FUCK YEAAAH!! Just got to the "I see dead people" scene. Much awesomeness. CrundyTalk nerdy to me 00:08, 17 November 2009 (UTC) - Nice. I may have to go watch it on Youtube just for that part. Tetronian you're clueless 00:10, 17 November 2009 (UTC) - No no, doovde is the way to go. CrundyTalk nerdy to me 00:18, 17 November 2009 (UTC) - Seriously, I love this moment so much I want to have sex with it, and have lots of little moments (which would be 6th sense and alcohol related) CrundyTalk nerdy to me 00:19, 17 November 2009 (UTC) - Oh, by the way, did you ever see the "Spaced" piss-take of 6th sense? Awesomeness. CrundyTalk nerdy to me 00:25, 17 November 2009 (UTC) - You lucky bastard, you sound like you are floating on air right now. Just make sure you can remember this bliss tomorrow morning. And yeah, I've seen that. Awesomeness is right. Tetronian you're clueless 00:27, 17 November 2009 (UTC) - I honestly can't recommend this wine recipe enough. Absoltely incredible. Seriously, give it a try. CrundyTalk nerdy to me 00:33, 17 November 2009 (UTC) - Sure. My dad makes some kind of dry red wine in his garage, so I'm no stranger to homebrew. Tetronian you're clueless 00:35, 17 November 2009 (UTC) - (Poisoned small girl funeral scene) Can I just point out that if it wasn't for woo-merchants and bullshit-peddlars the world over, we wouldn't have severe win movies like this? Viva la bollocks!! CrundyTalk nerdy to me 00:44, 17 November 2009 (UTC) - Hell yeah! Life would be boring without bullshit. Tetronian you're clueless 00:47, 17 November 2009 (UTC) (UI) Ohshitohshitohshit, gonna cry. It's the car scene. CrundyTalk nerdy to me 00:59, 17 November 2009 (UTC) I cut a piece of paper in half with another piece of paper[edit] For some reason I am immensely proud of this. Stupid evil Phantom! 10:21, 15 November 2009 (UTC) - Gosh, I wish my Sundays were as exciting as yours. --PsygremlinSnakk! 10:35, 15 November 2009 (UTC) - It was actually on Friday, I just forgot to mention it. Stupid evil Phantom! 11:07, 15 November 2009 (UTC) - remind me never to play scissors paper stone with you. Totnesmartin 17:21, 15 November 2009 (UTC) Well since no one asked I guess I have to: how? Tetronian you're clueless 03:30, 16 November 2009 (UTC) - Mei seconds this. Mei - The first piece of paper is money, with it you go and buy a scissors. Cut the second with the scissors. Voila! --The Emperor Kneel before Zod! 03:40, 16 November 2009 (UTC) - I sawed at one with the edge of the other. Stupid evil Phantom! 17:25, 16 November 2009 (UTC) - Wow. How long did that take? Tetronian you're clueless 17:47, 16 November 2009 (UTC) - Between half an hour and an hour. Stupid evil Phantom! 17:49, 16 November 2009 (UTC) - Actually, it may have been less; I wasn't counting. Stupid evil Phantom! 17:53, 16 November 2009 (UTC) - That's pretty cool. I respect anyone who has the time, initiative, and skill to cut paper with paper. Tetronian you're clueless 18:00, 16 November 2009 (UTC) - Outstanding work, well done Sir! Keep it up. DeltaStarSenior SysopSpeciationspeed! 22:28, 17 November 2009 (UTC) Quick brag[edit] Holy fuck! I just racked off my latest homebrew wine into my serving box, and I kid you not, it's fucking awesome. Absolutely incredible. Comparible to a £10 bottle of supermarket wine, and yet it cost me less than 50p a bottle. This honebeww laarky is a fduck1ng godo 21hobbe i tell ya hdjythdrunk11! CrundyTalk nerdy to me 23:07, 16 November 2009 (UTC) - Shit, I think I might have spilt my smack supply into this wine, because the sheer smooth feeling of awesomeness should not be achieved through alcohol alone. It really is that good. CrundyTalk nerdy to me 00:03, 17 November 2009 (UTC) - Very mashed now, and I sjhould point out tht I flushed a gram of mephedrone (4-mmc) earlier because I knew it was no good for me. being fucked on homebrew as I am I realise how much of aq good decisions that was. CrundyTalk nerdy to me 00:46, 17 November 2009 (UTC) - What the hell are you doing with a gram of mephedrone? Take it easy man.--EcheNegraMente This machine is obsolete 07:32, 17 November 2009 (UTC) - I would be very surprised if your homebrew really is comparable with a £10 barrel-aged wine although it may well be adequate for everyday drinking. I know that I have made and tasted quite a few homebrewed wines and you can't get the complexity and roundness of flavour in small quantities fermented and condtioned only in polythene or glass. ГенгисRationalWiki GOLD member 23:52, 17 November 2009 (UTC) - Depends on what you do with it. I used Lalvin ICV/D47 yeast and left on secondary lees for a month. The mouth feel is excellent. Very smooth and creamy. CrundyTalk nerdy to me 12:09, 18 November 2009 (UTC) Gold Standard Video[edit] It's surprisingly intelligent sounding, please tell me if this video is reasonable at all: --Mustex 01:44, 17 November 2009 (UTC) - Not really, printing money is largely a figure of speech. The Government borrows money in the form of bonds, essentially taking the money out against future taxation. This increases interests rates, as they have to pay the money back with interest, and devalues money - what we call inflation. He is right only in a figurative sense. I remember reading somewhere once that if everyone went to the bank and asked for their money we would only have enough legal tender to cover about 1/4 to 1/3 of it any way. Money is extremely fictitious these days. When was the last time you were actual paid your wages other than by electronic transfer? Money is actual the measure of the perceived value of a persons time. - π 04:16, 17 November 2009 (UTC) - Yeah, it's funny, really. Most of the "money" that passes through my "hands" never exists as any form of legal tender that I know of. Checks and EFTs handle most of the work. ħuman 20:56, 17 November 2009 (UTC) - CHEQUES!!!! Stupid evil Phantom! 21:00, 17 November 2009 (UTC) - Not for us 'Merkins. Tetronian you're clueless 21:20, 17 November 2009 (UTC) - The interesting thing is that while checks pretty much represent some "money" that must already exist (or they'll bounce...), EFTs can be purely fictional - essentially privately printed money. Hmm, wait, no that's not really true. Customer gets credit card, bank is "creating" the potential for money by offering a loan. Customer uses it to buy parts from me, when I charge their card the bank pays me with "real" money, which if they didn't have on hand, they borrow, ultimately from the money printers. So I guess the private sector can't run "too far" ahead of the government agencies in "creating money". The real art for the Govt is to only create as much new money as represented by wealth creation in the economy, with perhaps a slight overspill (at the cost of "some" inflation) to make sure future growth is not held back. The wealth is created just as gold is mined - by people putting the value of their time into the economy, with the result being worth more than their time. Since we need a way to exchange the "more" part, we need an increasing money supply. Oh, and, yeah, the "gold standard" would strangle an economy by limiting growth to how much gold can be mined. ħuman 21:40, 17 November 2009 (UTC) - Not surprisingly, much of this has been thought of all ready, and by a Canadian no less. Tetronian you're clueless 21:44, 17 November 2009 (UTC) For UK RationalWikians[edit] For those interested in politics and rational scepticism (whatever that is) some guy left a post in the forums that may interest you. - π 12:23, 17 November 2009 (UTC) - Rational skepticism is basically rationalism. It differs from philosophical skepticism in that it only questions non-falsifiable claims. Tetronian you're clueless 20:56, 17 November 2009 (UTC) Magnetic water treatment - woo?[edit] Since we're now in the business of debunking consumer products sold by footpads and bloodsucking insects, I'm wondering about this one - It claims to treat hard water using special magnets at $389 you clamp onto your incoming pipes. "This amazing magnetic effect super-cleans the interior of water pipes, reducing the extensive damage to these surfaces caused by build-up of lime scale. By changing the physical characteristics of water, hard water will perform like soft water." Is anyone here familiar with the science around this and whether there is anything to it? It sounds like rank woo to me. But if not, it's a lot cheaper than a conventional water treatment system. Here's another company selling something similar, and they even have a science page: And this "electronic water conditioner" that appears to possibly just be an electromagnet: Secret Squirrel 23:35, 17 November 2009 (UTC) - Well, first, scalefighter can't even spell "TARTER". Second, yeah, I think it's complete woo. What exactly is the magnet going to do to the calcium/magnesium, etc.? I have a magnetizer and raw ceramic magnets so I could experiment, but... I have virtually 0 ppm soft water (just a little iron and sulfur, if I can trust my senses). ħuman 00:21, 18 November 2009 (UTC) - Interestingly the Scalefighter website has a "science" page that cites what appear to be real journals, with claims a magnetic water treatment alters calcite to aragonite. Assuming this is valid in the first place, is argonite less likely to cause scaling and buildup than calcite? They're both CaCO3. Then there are too many other variables: what sort of magnetic fields were used in these studies and how do they compare to magnets you clamp on your pipes? What if the stuff clogging my pipes isn't calcite to begin with? Then of course they cite studies but one would have to read the whole thing to draw any conclusions from them or even whether the studies were conducted properly; an abstract doesn't cut it. I agree, still sounds like woo. Secret Squirrel 01:01, 18 November 2009 (UTC) - The same can be said of Purity Products' webshite giving so-called "scientifically proven" testimonials without citation. It's typical woo-meister mumbojumbo. Conservative Punk 01:05, 18 November 2009 (UTC) - I fixed ur link. - human - Well yeah, that and anyone can put four citations to scientific journals to make their product "look" scientifically based, even if the studies don't really have anything to do with what they're selling. It's having them there that counts. Most consumers are just going to skim it, see "magnetic" and "water" and not look further. I checked and they do appear to be real journals, but I have no idea if they're peer reviewed. Something for future research. Secret Squirrel 01:31, 18 November 2009 (UTC) - One of the papers theorizes that the magnet does something to silica causing it to outcompete the reformation of solid CaCO3, and I guess it forms a goo that flushes out? Not sure I want to drink that. Not even sure what sand is even doing in a potable water supply? How much Si is in "typical" hard water? ħuman 01:38, 18 November 2009 (UTC) - There should be very little of either silicon or silica (not the same), as in single milligrams per liter. Methods for measuring water hardness almost always look at calcium, magnesium, calcium carbonate, or calcium sulfate concentrations, which seem to be more soluble in water and harder to remove. Water is a polar molecule, so magnetic fields can exert forces on it, but putting a magnet around the pipe results in a field running along the pipe that doesn't change the flow in any significant way. It isn't going to change the flow or behavior of the ions or other dissolved stuff, either. OneForLogic 08:10, 18 November 2009 (UTC) Capturebot space saving proposal?[edit] Know ye that I know fuck all about computers. Now, about my idea: I seem to recall that RW was having problems over the huge amount of CP screencaps taken for use in WIGO. While the screencaps are really useful in case something is oversighted, some of them aren't necessary; the CP sysops can't delete the block log (AFAIK) but capturebot still takes a picture of the log when someone links to it. Similarly for deletions. Also for posts by Andy; I can't see any admin oversighting them and living to tell the tale. Could the bot be programmed to not take pictures of edits filling the above criteria, and would this be desirable? EddyP 13:19, 18 November 2009 (UTC) - "I used to skip certain links to log files or anchored talk pages but I think I removed those restrictions once we got 300gigs of space" -- Nx / talk 13:24, 18 November 2009 (UTC) Procrastination[edit] Anyone have any tips for beating this? I'm a uni student and my procrastinating tendency, combined with a high workload, is getting pretty annoying. Drinking vodka while working only helps a little bit. EddyP 21:17, 17 November 2009 (UTC) - I hate to say this but my worst source of procrastination is RW. I don't have a solution to your problem, though, as I can barely solve my own. Tetronian you're clueless 21:19, 17 November 2009 (UTC) - You could try to develop some sort of power word that you habitually repeat in order to foster motivation. Something like if-i-keep-dicking-around-I'll-become-a-loser-and-a-alcoholic should work. Perhaps some creative avoidance? Do some chores. Me!Sheesh!Mine! 21:24, 17 November 2009 (UTC) - I was a procrastinator at university until I saw my grades drop to the point that I couldn't get into the School of Pharmacy, and my procrastination stopped immediately. Aboriginal Noise Punkrock 21:35, 17 November 2009 (UTC) - I was pretty bad at uni too. The only thing I can suggest is to tell yourself that doing your work as soon as it's been assigned to you will allow you to reward yourself with a good piss-up afterwards. Do this once and the sense of relief should be enough to convince you to get your work out of the way quickly in the future. CrundyTalk nerdy to me 12:12, 18 November 2009 (UTC) - Rewards are good. Also, it's a good idea to set your own deadlines - obviously in advance of the real deadlines. Milestones also useful, particularly in larger assignments. It helps you keep track of your progress, and you get a decent feeling of achievement as you reach your milestones. You might want to have someone else checking in on your progress. I do this once a week with my projects and it generally keeps me on track. --Ask me about your mother 18:33, 18 November 2009 (UTC) Meet "A Conservapedian" Live this Wednesday...[edit] Apparently Andy has broken from his usual M.O. and announcedimg one of his public speaking appearances while there's still time to attend. Here is the Facebook invitation for anyone who's able to make it to the Rutger's campus tomorrow evening (11/18) at 8:00 PM. It'll be interesting to see if Ed Poor or any of the other NY/NJ acolytes show up as well. --SpinyNorman 22:08, 17 November 2009 (UTC) I will be on the livingston campus and will be getting out at 7:30, would anyone mind if I write an investigative piece on it? Greepigfoot--If you want to experience the medieval rituals of faith, the candle light, the incense, music, important-sounding dead languages, nobody does it better than the Catholics 00:54, 18 November 2009 (UTC) - Video or a mp3 would be nice.--Thanatos 01:17, 18 November 2009 (UTC) - Or audio. Yes, please take notes- I wish I could go. Hopefully somebody will ask Andy if he believes that Obama is using mind control techniques to pass health care reform, seeing as how the AAPS, in their fake journal, accused Obama of doing the same to get elected [5]. Corry 03:48, 18 November 2009 (UTC) - I would die to see Andy looking over his shoulders waiting for someone to "block" a real live person arguing with him... I so hope Rutgers posts video of this event. ħuman 04:37, 18 November 2009 (UTC) - It could well be like the handful of times Rush Limbaugh has ventured into a forum where he's not in complete control and dealing with a sympathetic audience. He will make a complete ass off himself. - For instance, - * When Pat Sajak had a late night talk show on CBS, Limbaugh guest hosted for him for a week or so. Some people opposed to Limbaugh (gay activists from ACT-UP, I think) managed to get into the audience one night, with the express intent of disrupting things. It got so bad they cleared the entire audience. - * Limbaugh once appeared as a guest on David Letterman's show. Letterman asked him, point blank, "does it ever occur to you that you're nothing more than a ball of hot gas?" Limbaugh was speechless. - Just like any bully, when people like Schlafly are confronted and they can't control the situation, they lose quickly and thoroughly. MDB 18:12, 18 November 2009 (UTC) Quote[edit] I'm writing a paper at uni and found this quote in the book "The Rise and Fall of Phil Spector" (He was a record producer.) The first man this made me think of was Andrew Schlafly. SJ Debaser 14:10, 18 November 2009 (UTC) - That's a great quote. I'm going to write that down. Tetronian you're clueless 14:22, 18 November 2009 (UTC) - Except in this case the unreasonable man doesn't want progress - he thinks everything has been going downhill for the last 6,000 years. –SuspectedReplicantretire me 14:25, 18 November 2009 (UTC) - All Andy controls is Conservapedia, and he is under the illusion that that is progressing - which is arguable, as it has gained more attention in the last year. Although the actual efficiency of his editors? No progress obviously, they chase away the worthwhile ones. SJ Debaser 14:40, 18 November 2009 (UTC) - Andy isn't trying to adapt the world to himself. He's just adapted a virtual one instead. EddyP 15:51, 18 November 2009 (UTC) - Dude, I totally just Facebooked that. No, I'm not kidding, I really did. I have a lot of Christian friends and I enjoy pissing them off." SirChuckBThis country needs more Rutabegas 21:08, 18 November 2009 (UTC)
https://rationalwiki.org/wiki/RationalWiki:Saloon_bar/Archive41
CC-MAIN-2022-21
refinedweb
24,075
71.34
I’m migrating from 1.4.0 to 2.3.0 and came across this issue which also occurs in 2.2.2 Currently I’m not sure whether I was originally doing things incorrectly, or whether this is a regression break. I’ve boiled it down to a minimal test case. Essentially, I want to fix the x_range between 2 specific dates, then plot some stuff. In 1.4.0 I get this; But in 2.2.2 and 2.3.0dev3 I get the javascript error; Self-contained minmal example; from bokeh.models import DatetimeTickFormatter, Range1d from bokeh.plotting import curdoc, figure from datetime import date # Get a reference to the document we will be creating doc = curdoc() # create a new plot with a title and axis labels. Set range to be 1st Jan 2020 to 31st Dec 2020 plot = figure( title="simple line example", x_axis_label='x', y_axis_label='y', x_range=Range1d(start=date(2020, 1, 1), end=date(2020, 12, 31)) ) # plot a line through three dates x = [date(2020, 3, 1), date(2020, 4, 1), date(2020, 5, 1)] y = [1, 2, 3] plot.line(x, y, legend_label="Temp.", line_width=2) # Format the x-axis nicely plot.xaxis.formatter = DatetimeTickFormatter(days=['%Y-%m-%d'], months=['%Y-%m-%d'], years=['%Y-%m-%d']) # Put the plot into the document doc.add_root(plot)
https://discourse.bokeh.org/t/range1d-throwing-error-with-dates-between-1-4-0-and-2-2-2-and-2-3-0dev3/6620
CC-MAIN-2020-50
refinedweb
224
68.06
A provider exposes functionality to your actions. Typically to run side effects. Each action has a unique context object where the providers are populated. This provider is automatically wrapped by the debugger, where available. export const greetProvider = { greet() { return 'hello' } } import * as providers from './providers' export default { providers } You also have access to the context inside your provider. This will allow you to leverage existing providers. The context is exposed as this.context. This keeps the API concise and under the hood we can do prototypal optimizations. export default { triggerSignalOnNativeEvent(event, sequence) { window.addEventListener(event, () => { this.context.get(sequence)() }) } } You can optionally use the Provider factory. It allows you to pass some potions related to debugging: import { Provider } from 'cerebral' export const myProvider = Provider({}, { wrap: false }) This provider will not be tracked by debugger. Optionally you can intercept how the provider should work when wrapped by the devtools: import { Provider } from 'cerebral' export const myProvider = Provider({}, { wrap(context) { return {} } }) A provider can also by defined as a function which receives the current context. This prevents some optimizations, but might be necessary: export const greetProvider = (context) => { return {} }
https://cerebraljs.com/docs/api/providers.html
CC-MAIN-2019-26
refinedweb
186
50.12
projects / gnupg.git / blobdiff commit grep author committer pickaxe ? search: re summary | shortlog | log | commit | commitdiff | tree raw | inline | side by side Fixed card key generation of gpg2. [gnupg.git] / NEWS diff --git a/NEWS b/NEWS index 9746e02 .. 322bcd2 100644 (file) --- a/ NEWS +++ b/ NEWS @@ -1,1850 +1,515 @@ -Noteworthy changes in version 1.4.3 +Noteworthy changes in version 2.0.5 ------------------------------------------------ - * model option. - This is an optional trust model on top of the standard ones. It - make use of of special DNS records and notation data to - associate a mail address with an OpenPGP key. See: XXXX for a - description. - - *. - - -Noteworthy changes in version 1.4.2 (2005-07-26) ------------------------------------------------- - - *. + * Switched license to GPLv3. - * Fixed a couple of problems with the card reader. + * Basic support for Windows. Run "./autogen.sh --build-w32" to build + it. As usual the mingw cross compiling toolchain is required. - * Command completion is now available in the --edit-key and - --card-edit menus. Filename completion is available at all - filename prompts. Note that completion is only available if the - system provides a readline library. + * Fixed bug when using the --p12-charset without --armor. - * New experimental HKP keyserver helper that uses the cURL - library. It is enabled via the configure option --with-libcurl - like the other (also experimental) cURL helpers. + * The command --gen-key may now be used instead of the + gpgsm-gencert.sh script. - *. + * Changed key generation to reveal less information about the + machine. Bug fixes for gpg2's card key generation. - * New export option export-reset-subkey-passwd. - * New option --limit-card-insert-tries. - - -Noteworthy changes in version 1.4.1 (2005-03-15) +Noteworthy changes in version 2.0.4 (2007-05-09) ------------------------------------------------ - *) -------------------------------------------------- - - * Ask the user to repeat a changed PIN. + * The server mode key listing commands are now also working for + systems without the funopen/fopencookie API. - * Switched to automake 1.9. Minor big fixes. + * PKCS#12 import now tries several encodings in case the passphrase + was not utf-8 encoded. New option --p12-charset for gpgsm. - . - - -Noteworthy changes in version 1.3.91 (2004-10-15) -------------------------------------------------- - - * A new configure option --enable-selinux-support disallows - processing of confidential files used by gpg (e.g. secring.gpg). - This helps writing ACLs for the SELinux kernel. + * Improved the libgcrypt logging support in all modules. - *. - - -Noteworthy changes in version 1.3.90 (2004-10-01) -------------------------------------------------- - - * Readline support at all prompts is now available if the system - provides a readline library. The build time option - --without-readline may be used to disable this feature. - - *) +Noteworthy changes in version 2.0.3 (2007-03-08) ------------------------------------------------ - *. + *. [CVE-2007-1263]. - *. + * New --verify-option show-primary-uid-only. - * Support for fetching keys via HTTP has been added. This is - mainly useful for setting a preferred keyserver URL like - "" . + * gpgconf may now reads a global configuration file to select which + options are changeable by a frontend. The new applygnupgdefaults + tool may be used by an admin to set default options for all users . - * New --ask-cert-level/--no-ask-cert-level option to turn on and - off the prompt for signature level when signing a key. Defaults - to off. + * The PIN pad of the Cherry XX44 keyboard is now supported. The + DINSIG and the NKS applications are now also aware of PIN pads. - * New --gpgconf-list command for internal use by the gpgconf - utility from gnupg 1.9.x. - -Noteworthy changes in version 1.3.5 (2004-02-26) +Noteworthy changes in version 2.0.2 (2007-01-31) ------------------------------------------------ - * New --min-cert-level option to disregard key signatures that are - under a specified level. Defaults to 2 (i.e. discard 0x11 - signatures). - - *. - - * Some performance improvements with large keyrings. See the - build time option --enable-key-cache=SIZE in the README file for - details. - - * Some portability fixes for the OpenBSD/i386, HPPA, and AIX - platforms. + * Fixed a serious and exploitable bug in processing encrypted + packages. [CVE-2006-6235]. - * New keyserver-option "http-proxy" to specify which proxy to use - in the config file without using environment variables. + * Added --passphrase-repeat to set the number of times GPG will + prompt for a new passphrase to be repeated. This is useful to help + memorize a new passphrase. The default is 1 repetition. - * Added support for storing, retrieving, and searching for keys in - LDAP servers. Note that this is different than the "LDAP - keyserver" which was already (and remains) supported. + * Using a PIN pad does now also work for the signing key. - * Added support for TLS and LDAPS session encryption for LDAP. + * A warning is displayed by gpg-agent if a new passphrase is too + short. New option --min-passphrase-len defaults to 8. - * --show-session-key/--override-session-key now works with - --symmetric messages. + * The status code BEGIN_SIGNING now shows the used hash algorithms. - *.3.4 (2003-11-27) +Noteworthy changes in version 2.0.1 (2006-11. + * Experimental support for the PIN pads of the SPR 532 and the Kaan + Advanced card readers. Add "disable-keypad" scdaemon.conf if you + don't want it. Does currently only work for the OpenPGP card and + its authentication and decrypt keys. - * Support for Elgamal sign+encrypt keys has been removed. Old - signatures may still be verified, and existing encrypted - messages may still be decrypted, but no new signatures may be - issued by, and no new messages will be encrypted to, these keys. + * Fixed build problems on some some platforms and crashes on amd64. + * Fixed a buffer overflow in gpg2. [bug#728,CVE-2006-6169] -Noteworthy changes in version 1.3.3 (2003-10-10) ------------------------------------------------- - *. - - *. - - * A number of portability changes to make building GnuPG on - less-common platforms easier. - - -Noteworthy changes in version 1.3.2 (2003-05-27) +Noteworthy changes in version 2.0.0 (2006-11-11) ------------------------------------------------ - *. - - * Notation names that do not contain a '@' are no longer allowed - unless --expert is set. This is to help prevent pollution of - the (as yet unused) IETF notation namespace. + * First stable version of a GnuPG integrating OpenPGP and S/MIME. - * Multiple trust models are now supported via the --trust-model - option. The options are "pgp" (web-of-trust plus trust - signatures), "classic" (web-of-trust only), and "always" - (identical to the --always-trust option). - * The --personal-{cipher|digest|compression}-preferences are now - consulted to get default algorithms before resorting to the - last-ditch defaults of --s2k-cipher-algo, SHA1, and ZIP - respectively. This allows a user to set algorithms to use in a - safe manner so they are used when legal to do so, without - forcing them on for all messages. - - * New --primary-keyring option to designate the keyring that the - user wants new keys imported into. - - * --s2k-digest-algo is now used for all password mangling. - Earlier versions used both --s2k-digest-algo and --digest-algo - for passphrase mangling. +Noteworthy changes in version 1.9.95 (2006-11-06) +------------------------------------------------- - * Handling of --hidden-recipient or --throw-keyid messages is now - easier - the user only needs to give their passphrase once, and - GnuPG will try it against all of the available secret keys. + * Minor bug fixes. - * Care is taken to prevent compiler optimization from removing - memory wiping code. - * New option --no-mangle-dos-filenames so that filenames are not - truncated in the W32 version. +Noteworthy changes in version 1.9.94 (2006-10-24) +------------------------------------------------- - * A "convert-from-106" script has been added. This is a simple - script that automates the conversion from a 1.0.6 or earlier - version of GnuPG to a 1.0.7 or later version. + * Keys for gpgsm may now be specified using a keygrip. A keygrip is + indicated by a prefixing it with an ampersand. - * Disabled keys are now skipped when selecting keys for - encryption. If you are using the --with-colons key listings to - detect disabled keys, please see doc/DETAILS for a minor format - change in this release. + * gpgconf now supports switching the CMS cipher algo (e.g. to AES). - * Minor trustdb changes to make the trust calculations match - common usag e. + * New command --gpgconf-test for all major tools. This may be used to + check whether the configuration file is san e. - *. +Noteworthy changes in version 1.9.93 (2006-10-18) +------------------------------------------------- - * Add read-only support for the SHA-256 hash, and optional - read-only support for the SHA-384 and SHA-512 hashes . + * In --with-validation mode gpgsm will now also ask whether a root + certificate should be trusted . - * New option --enable-progress-filter for use with frontends . + * Link to Pth only if really necessary . - * DNS SRV records are used in HKP keyserver lookups to allow - administrators to load balance and select keyserver ports - automatically. This is as specified in - draft-shaw-openpgp-hkp-00.txt. + * Fixed a pubring corruption bug in gpg2 occurring when importing + signatures or keys with insane lengths. - * When using the "keyid!" syntax during a key export, only that - specified key is exported. If the key in question is a subkey, - the primary key plus only that subkey is exported. + * Fixed v3 keyID calculation bug in gpg2. - * configure --disable-xxx options to disable individual algorithms - at build time. This can be used to build a smaller gpg binary - for embedded uses where space is tight. See the README file for - the algorithms that can be used with this option, or use - --enable-minimal to build the smallest gpg possible (disables - all optional algorithms, disables keyserver access, and disables - photo IDs). + * More tweaks for certificates without extensions. - * The keyserver no-modify flag on a key can now be displayed and - modified. - *. +Noteworthy changes in version 1.9.92 (2006-10-11) +------------------------------------------------- + * Bug fixes. -Noteworthy changes in version 1.3.1 (2002-11-12) ------------------------------------------------- - * Trust signature support. This is based on the Maurer trust - model where a user can specify the trust level along with the - signature with multiple levels so users can delegate - certification ability to other users, possibly restricted by a - regular expression on the user ID. Note that full trust - signature support requires a regular expression parsing library. - The regexp code from glibc 2.3.1 is included for those platforms - that don't have working regexp functions available. The - configure option --disable-regex may be used to disable any - regular expression code, which will make GnuPG ignore any trust - signature with a regular expression included. - - * Two new commands --hidden-recipient (-R) and --hidden-encrypt-to - encrypt to a user, but hide. - - -Noteworthy changes in version 1.3.0 (2002-10-18) ------------------------------------------------- +Noteworthy changes in version 1.9.91 (2006-10-04) +------------------------------------------------- - * The last piece of internal keyserver support has been removed, - and now all keyserver access is done via the keyserver plugins. - There is also a newer keyserver protocol used between GnuPG and - the plugins, so plugins from earlier versions of GnuPG may not - work properly. + * New "relax" flag for trustlist.txt to allow root CA certificates + without BasicContraints. - * The HKP keyserver plugin supports the new machine-readable key - listing format for those keyservers that provide it . + * [gpg2] Removed the -k PGP 2 compatibility hack. -k is now an + alias for --list-keys . - * When using a HKP keyserver with multiple DNS records (such as - wwwkeys.pgp.net which has the addresses of multiple servers - around the world), try all records until one succeeds. Note - that it depends on the LDAP library used whether the LDAP - keyserver plugin does this as well. + * [gpg2] Print a warning if "-sat" is used instead of "--clearsign". - *). +Noteworthy changes in version 1.9.90 (2006-09-25) +------------------------------------------------- - * --trusted-key has been un-obsoleted, as it is useful for adding - ultimately trusted keys from the config file. It is identical - to using --edit and "trust" to change a key to ultimately - trusted. + * Made readline work for gpg. - * Translations other than de are no longer distributed with the - development branch. This is due to the frequent text changes - during development, which cause the translations to rapidly go - out of date. + * Cleanups und minor bug fixes. + * Included translations from gnupg 1.4.5. -Noteworthy changes in version 1.1.92 (2002-09-11) -------------------------------------------------- - * [IMPORTANT] The default configuration file is now - ~/.gnupg/gpg.conf. If an old ~/.gnupg/options is found it will - still be used. This change is required to have a more - consistent naming scheme with forthcoming tools. - - * option --interactive now has the desired effect when - importing keys. - - * configure option --with-static-rnd=auto allows to build gpg - with all available entropy gathering modules included. At - runtime the best usable one will be selected from the list - linux, egd, unix. This is also the default for systems lacking - a /dev/random device. - - * The default character set is now taken from the current locale; - it can still be overridden by the --charset option. Using the - option -vvv shows the used character set. - - * [REMOVED] --emulate-checksum-bug and --emulate-3des-s2k-bug have - been removed. - - -Noteworthy changes in version 1.1.91 (2002-08-04) +Noteworthy changes in version 1.9.23 (2006-09-18) ------------------------------------------------- - * All modules are now linked statically; the --load-extension - option is in general not useful anymore. The only exception is - to specify the deprecated idea cipher. + * Regular man pages for most tools are now build directly from the + Texinfo source. - * The IDEA plugin has changed. Previous versions of the IDEA - plugin will no longer work with GnuPG. However, the current - version of the plugin will work with earlier GnuPG versions. + *. - * When using --batch with one of the --delete-key commands, the - key must be specified by fingerprint. See the man page for - details. + * API change in gpg-agent's pkdecrypt command. Thus an older gpgsm + may not be used with the current gpg-agent. - * There are now various ways to restrict the ability GnuPG has to - exec external programs (for the keyserver helpers or photo ID - viewers). Read the README file for the complete list. + * The scdaemon will now call a script on reader status changes. - * New export option to leave off attribute packets (photo IDs) - during export. This is useful when exporting to HKP keyservers - which do not understand attribute packets. + * gpgsm now allows file descriptor passing for "INPUT", "OUTPUT" and - * gpgsm server may now output a key listing to the output file + handle. This needs to be enabled using "OPTION list-to-output=1". - *. + * The --output option of gpgsm has now an effect on list-keys. - * The LDAP keyserver handler now works properly with very old - (version 1) LDAP keyservers. + * New gpgsm commands --dump-chain and list-chain. + * gpg-connect-agent has new options to utilize descriptor passing. -Noteworthy changes in version 1.1.90 (2002-07-01) -------------------------------------------------- - - *. + * A global trustlist may now be used. See doc/examples/trustlist.txt. - * New "group" command to refer to several keys with one name. + * When creating a new pubring.kbx keybox common certificates are + imported. - * A warning is issued if the user forces the use of an algorithm - that is not listed in the recipient's preferences. - * Full revocation key (aka "designated revoker") support. +Noteworthy changes in version 1.9.22 (2006-07-27) +------------------------------------------------- - * The preferred hash algorithms on a key are consulted when - encrypting a signed message to that key. Note that this is - disabled by default by a SHA1 preference in - --personal-digest-preferences. + * Enhanced pkcs#12 support to allow import from simple keyBags. - * --cert-digest-algo allows the user to specify the hash algorithm - to use when signing a key rather than the default SHA1 (or MD5 - for PGP2 keys). Do not use this feature unless you fully - understand the implications of this. + * Exporting to pkcs#12 now create bag attributes so that Mozilla is + able to import the files. - * --pgp7 mode automatically sets all necessary options to ensure - that the resulting message will be usable by a user of PGP 7.x. + * Fixed uploading of certain keys to the smart card. - * New --attribute-fd command for frontends and scripts to get the - contents of attribute packets (i.e. photos) - * In expert mode, the user can now re-sign a v3 key with a v4 - self-signature. This does not change the v3 key into a v4 key, - but it does allow the user to use preferences, primary ID flags, - etc. +Noteworthy changes in version 1.9.21 (2006-06-20) +------------------------------------------------- - * Significantly improved photo ID support on non-unixlike - platforms. + * New command APDU for scdaemon to allow using it for general card + access. Might be used through gpg-connect-agent by using the SCD + prefix command. - * The version number has jumped ahead to 1.1.90 to skip over the - old version 1.1 and to get ready for the upcoming 1.2. + * Support for the CardMan 4040 PCMCIA reader (Linux 2.6.15 required). - * ElGamal sign and encrypt is not anymore allowed in the key - generation dialog unless in expert mode. RSA sign and encrypt - has been added with the same restrictions. + * Scdaemon does not anymore reset cards at the end of a connection. - * [W32] Keyserver access does work with Windows NT . + * Kludge to allow use of Bundesnetzagentur issued X.509 certificates . + * Added --hash=xxx option to scdaemon's PKSIGN command. -Noteworthy changes in version 1.0.7 (2002-04-29) ------------------------------------------------- + * Pkcs#12 files are now created with a MAC. This is for better + interoperability. - * Secret keys are now stored and exported in a new format which - uses SHA-1 for integrity checks. This format renders the - Rosa/Klima attack useless. Other OpenPGP implementations might - not yet support this, so the option --simple-sk-checksum creates - the old vulnerable format. + * Collected bug fixes and minor other changes. - * The default cipher algorithm for encryption is now CAST5, - default hash algorithm is SHA-1. This will give us better - interoperability with other OpenPGP implementations. - * Symmetric encrypted messages now use a fixed file size if - possible. This is a tradeoff: it breaks PGP 5, but fixes PGP 2, - 6, and 7. Note this was only an issue with RFC-1991 style - symmetric messages. +Noteworthy changes in version 1.9.20 (2005-12-20) +------------------------------------------------- - * Photographic user ID support. This uses an external program to - view the images . + * Importing pkcs#12 files created be recent versions of Mozilla works + again . - * Enhanced keyserver support via keyserver "plugins". GnuPG comes - with plugins for the NAI LDAP keyserver as well as the HKP email - keyserver. It retains internal support for the HKP HTTP - keyserver. + * Basic support for qualified signatures. - * Nonrevocable signatures are now supported. If a user signs a - key nonrevocably, this signature cannot be taken back so be - careful! + * New debug tool gpgparsemail. - * Multiple signature classes are usable when signing a key to - specify how carefully the key information (fingerprint, photo - ID, etc) was checked. - * --pgp2 mode automatically sets all necessary options to ensure - that the resulting message will be usable by a user of PGP 2.x. +Noteworthy changes in version 1.9.19 (2005-09-12) +------------------------------------------------- - * --pgp6 mode automatically sets all necessary options to ensure - that the resulting message will be usable by a user of PGP 6.x . + * The Belgian eID card is now supported for signatures and ssh. + Other pkcs#15 cards should work as well . - * Signatures may now be given an expiration date. When signing a - key with an expiration date, the user is prompted whether they - want their signature to expire at the same time. + * Fixed bug in --export-secret-key-p12 so that certificates are again + included. - * Revocation keys (designated revokers) are now supported if - present. There is currently no way to designate new keys as - designated revokers. - * Permissions on the .gnupg directory and its files are checked - for safety. +Noteworthy changes in version 1.9.18 (2005-08-01) +------------------------------------------------- - * --expert mode enables certain silly things such as signing a - revoked user id, expired key, or revoked key. + * [gpgsm] Now allows for more than one email address as well as URIs + and dnsNames in certificate request generation. A keygrip may be + given to create a request from an existing key. - * Some fixes to build cleanly under Cygwin32 . + * A couple of minor bug fixes . - * New tool gpgsplit to split OpenPGP data formats into packets. - * New option --preserve-permissions. +Noteworthy changes in version 1.9.17 (2005-06-20) +------------------------------------------------- - * Subkeys created in the future are not used for encryption or - . + * gpg-connect-agent has now features to handle Assuan INQUIRE + commands . - * Revoked user-IDs are not listed unless signatures are listed too - or we are in verbose mode. + * Internal changes for OpenPGP cards. New Assuan command WRITEKEY. - * There is no default comment string with ascii armors anymore - except for revocation certificates and --enarmor mode. + * GNU Pth is now a hard requirement. - * The command "primary" in the edit menu can be used to change the - primary UID, "setpref" and "updpref" can be used to change the - preferences. + * [scdaemon] Support for OpenSC has been removed. Instead a new and + straightforward pkcs#15 modules has been written. As of now it + does allows only signing using TCOS cards but we are going to + enhance it to match all the old capabilities. - * Fixed the preference handling; since 1.0.5 they were erroneously - matched against against the latest user ID and not the given one . + * [gpg-agent] New option --write-env-file and Assuan command + UPDATESTARTUPTTY . - * RSA key generation. + * [gpg-agent] New option --default-cache-ttl-ssh to set the TTL for + SSH passphrase caching independent from the other passphrases. - * Merged Stefan's patches for RISC OS in. See comments in - scripts/build-riscos. - * It is now possible to sign and conventional encrypt a message (-cs). +Noteworthy changes in version 1.9.16 (2005-04-21) +------------------------------------------------- - * The MDC feature flag is supported and can be set by using - the "updpref" edit command . + * gpg-agent does now support the ssh-agent protocol and thus allows + to use the pinentry as well as the OpenPGP smartcard with ssh . - * The status messages GOODSIG and BADSIG are now returning the primary - UID, encoded using %XX escaping (but with spaces left as spaces, - so that it should not break too much) + * New tool gpg-connect-agent as a general client for the gpg-agent. - * Support for GDBM based keyrings has been removed . + * New tool symcryptrun as a wrapper for certain encryption tools . - * The entire keyring management has been revamped. + * The gpg tool is not anymore build by default because those gpg + versions available in the gnupg 1.4 series are far more matured. - * The way signature stati are store has changed so that v3 - signatures can be supported. To increase the speed of many - operations for existing keyrings you can use the new - --rebuild-keydb-caches command. - * The entire key validation process (trustdb) has been revamped. - See the man page entries for --update-trustdb, --check-trustdb - and --no-auto-check-trustdb. +Noteworthy changes in version 1.9.15 (2005-01-13) +------------------------------------------------- - * --trusted-keys is again obsolete, --edit can be used to set the - ownertrust of any key to ultimately trusted. + * Fixed passphrase caching bug. - * A subkey is never used to sign keys. + * Better support for CCID readers; the reader from Cherry RS 6700 USB + does now work. - * Read only keyrings are now handled as expected. +Noteworthy changes in version 1.9.14 (2004-12-22) +------------------------------------------------- -Noteworthy changes in version 1.0.6 (2001-05-29) ------------------------------------------------- + * [gpg-agent] New option --use-standard-socket to allow the use of a + fixed socket. gpgsm falls back to this socket if GPG_AGENT_INFO + has not been set. - * Security fix for a format string bug in the tty code . + * Ported to MS Windows with some functional limitations . - * Fixed format string bugs in all PO files. + * New tool gpg-preset-passphrase. - * Removed Russian translation due to too many bugs. The FTP - server has an unofficial but better translation in the contrib - directory. - * Fixed expire time calculation and keyserver access. +Noteworthy changes in version 1.9.13 (2004-12-03) +------------------------------------------------- - * The usual set of minor bug fixes and enhancements . + * [gpgsm] New option --prefer-system-dirmngr . - * non-writable keyrings are now correctly handled . + * Minor cleanups and debugging aids . -Noteworthy changes in version 1. 0.5 (2001-04-29 ) ------------------------------------------------- +Noteworthy changes in version 1. 9.12 (2004-10-22 ) +------------------------------------------------ - - *. + * [scdaemon] Partly rewrote the PC/SC code. - * WARNING: Corrected hash calculation for input data larger than - 512M - it was just wrong, so you might notice bad signature in - some very big files. It may be wise to keep an old copy of - GnuPG around. + * Removed the sc-investigate tool. It is now in a separate package + available at . - * Secret keys are no longer imported unless you use the new option - --allow-secret-key-import. This is a kludge and future versions will - handle it in another way. + * [gpg-agent] Fixed logging problem. - *. +Noteworthy changes in version 1.9.11 (2004-10-01) +------------------------------------------------- - * New --charset=utf-8 to bypass all internal conversions. + * When using --import along with --with-validation, the imported + certificates are validated and only imported if they are fully + valid. - * Large File Support (LFS) is now working . + * [gpg-agent] New option --max-cache-ttl . - * New options: --ignore-crc-error, --no-sig-create-check, - --no-sig-cache, --fixed-list-mode, --no-expensive-trust-checks, - --enable-special-filenames and --use-agent. See man page. + * [gpg-agent] When used without --daemon or --server, gpg-agent now + check whether a agent is already running and usable. - * New command --pipemode, which can be used to run gpg as a - co-process. Currently only the verification of detached - signatures are working. See doc/DETAILS. + * Fixed some i18n problems. - * Keyserver support for the W32 version. - * Rewritten key selection code so that GnuPG can better cope with - multiple subkeys, expire dates and so. The drawback is that it - is slower. +Noteworthy changes in version 1.9.10 (2004-07-22) +------------------------------------------------- - * A whole lot of bug fix es. + * Fixed a serious bug in the checking of trusted root certificat es. - * configure option --enable-agent-pnly allows to build and + install just the agent. - * New translations: Estonian, Turkish . + * Fixed a problem with the log file handling . -Noteworthy changes in version 1. 0.4 (2000-10-17 ) +Noteworthy changes in version 1. 9.9 (2004-06-08 ) ------------------------------------------------ - *. + * [gpg-agent] The new option --allow-mark-trusted is now required to + allow gpg-agent to add a key to the trustlist.txt after user + confirmation. - * Rijndael (AES) is now supported and listed with top preferenc e. + * Creating PKCS#10 requests does now honor the key usag e. - * --with-colons now works with --print-md[s]. -Noteworthy changes in version 1. 0.3 (2000-09-18 ) +Noteworthy changes in version 1. 9.8 (2004-04-29 ) ------------------------------------------------ - * Fixed problems with piping to/from other MS-Windows software - - * Expiration time of the primary key can be changed again. - - * Revoked user IDs are now marked in the output of --list-key - - * New options --show-session-key and --override-session-key - to help the British folks to somewhat minimize the danger - of this Orwellian RIP bill. - - * New options --merge-only and --try-all-secrets. - - * New configuration option --with-egd-socket. - - * The --trusted-key option is back after it left us with 0.9.5 - - * RSA is supported. Key generation does not yet work but will come - soon. - - * CAST5 and SHA-1 are now the default algorithms to protect the key - and for symmetric-only encryption. This should solve a couple - of compatibility problems because the old algorithms are optional - according to RFC2440 - - * Twofish and MDC enhanced encryption is now used. PGP 7 supports - this. Older versions of GnuPG don't support it, so they should be - upgraded to at least 1.0.2 - - -Noteworthy changes in version 1.0.2 (2000-07-12) ----------------------------------------------- - - * Fixed expiration handling of encryption keys. - - * Add an experimental feature to do unattended key generation. - - * The user is now asked for the reason of revocation as required - by the new OpenPGP draft. - - * There is a ~/.gnupg/random_seed file now which saves the - state of the internal RNG and increases system performance - somewhat. This way the full entropy source is only used in - cases were it is really required. - Use the option --no-random-seed-file to disable this feature. - - * New options --ignore-time-conflict and --lock-never. - - * Some fixes for the W32 version. - - * The entropy.dll is not anymore used by the W32 version but replaced - by code derived from Cryptlib. - - * Encryption is now much faster: About 2 times for 1k bit keys - and 8 times for 4k keys. - - * New encryption keys are generated in a way which allows a much - faster decryption. - - * New command --export-secret-subkeys which outputs the - the _primary_ key with it's secret parts deleted. This is - useful for automated decryption/signature creation as it - allows to keep the real secret primary key offline and - thereby protecting the key certificates and allowing to - create revocations for the subkeys. See the FAQ for a - procedure to install such secret keys. - - * Keygeneration now writes to the first writeable keyring or - as default to the one in the homedirectory. Prior versions - ignored all --keyring options. - - * New option --command-fd to take user input from a file descriptor; - to be used with --status-fd by software which uses GnuPG as a backend. - - * There is a new status PROGRESS which is used to show progress during - key generation. - - * Support for the new MDC encryption packets. To create them either - --force-mdc must be use or cipher algorithm with a blocksize other - than 64 bits is to be used. --openpgp currently disables MDC packets - entirely. This option should not yet be used. - - * New option --no-auto-key-retrieve to disable retrieving of - a missing public key from a keyserver, when a keyserver has been set. - - * Danish translation - -Noteworthy changes in version 1.0.1 (1999-12-16) ------------------------------------ - - * New command --verify-files. New option --fast-list-mode. - - * $http_proxy is now used when --honor-http-proxy is set. - - * Fixed some minor bugs and the problem with conventional encrypted - packets which did use the gpg v3 partial length headers. - - * Add Indonesian and Portugese translations. - - * Fixed a bug with symmetric-only encryption using the non-default 3DES. - The option --emulate-3des-s2k-bug may be used to decrypt documents - which have been encrypted this way; this should be done immediately - as this workaround will be remove in 1.1 - - * Can now handle (but not display) PGP's photo IDs. I don't know the - format of that packet but after stripping a few bytes from the start - it looks like a JPEG (at least my test data). Handling of this - package is required because otherwise it would mix up the - self signatures and you can't import those keys. - - * Passing non-ascii user IDs on the commandline should now work in all - cases. - - * New keys are now generated with an additional preference to Blowfish. - - * Removed the GNU Privacy Handbook from the distribution as it will go - into a separate one. - - -Noteworthy changes in version 1.0.0 (1999-09-07) ------------------------------------ - - * Add a very preliminary version of the GNU Privacy Handbook to - the distribution (lynx doc/gph/index.html). - - * Changed the version number to GnuPG 2001 ;-) - - -Noteworthy changes in version 0.9.11 ------------------------------------- - - * UTF-8 strings are now correctly printed (if --charset is set correctly). - Output of --with-colons remains C-style escaped UTF-8. - - * Workaround for a problem with PGP 5 detached signature in textmode. - - * Fixed a problem when importing new subkeys (duplicated signatures). - -Noteworthy changes in version 0.9.10 ------------------------------------- - - * Some strange new options to help pgpgpg - - * Cleaned up the dox a bit. - - -Noteworthy changes in version 0.9.9 ------------------------------------ - - * New options --[no-]utf8-strings. - - * New edit-menu commands "enable" and "disable" for entire keys. - - * You will be asked for a filename if gpg cannot deduce one. - - * Changes to support libtool which is needed for the development - of libgcrypt. - - * ------------------------------------ - - * New subcommand "delsig" in the edit menu. - - * The name of the output file is not anymore the one which is - embedded in the processed message, but the used filename with - the extension stripped. To revert to the old behaviour you can - use the option --use-embedded-filename. - - * Another hack to cope with pgp2 generated detached signatures. - - * latin-2 character set works (--charset=iso-8859-2). - - * New option --with-key-data to list the public key parameters. - New option -N to insert notations and a --set-policy-url. - A couple of other options to allow reseting of options. - - * Better support for HPUX. - - -Noteworthy changes in version 0.9.7 ------------------------------------ - - * Add some work arounds for a bugs in pgp 2 which led to bad signatures - when used with canonical texts in some cases. - - * Enhanced some status outputs. - -Noteworthy changes in version 0.9.6 ------------------------------------ - - * Twofish is now statically linked by default. The experimental 128 bit - version is now disabled. Full support will be available as soon as - the OpenPGP WG has decided on an interpretation of rfc2440. - - * Dropped support for the ancient Blowfish160 which is not OpenPGP. - - * Merged gpgm and gpg into one binary. - - * Add "revsig" and "revkey" commands to the edit menu. It is now - possible to revoke signature and subkeys. - - -Noteworthy changes in version 0.9.5 ------------------------------------ - - * New command "lsign" in the keyedit menu to create non-exportable - signatures. Removed --trusted-keys option. - - * A bunch of changes to the key validation code. - - * --list-trust-path now has an optional --with-colons format. - - * New command --recv-keys to import keys from an keyserver. - - .3 ------------------------------------ - - * Changed the internal design of getkey which now allows a - efficient lookup of multiple keys and add a word match mode. - - * New options --[no-]encrypt-to. - - * Some changes to the configure stuff. Switched to automake 1.4. - Removed intl/ from CVS, autogen.sh now uses gettextize. - - * Preferences now include Twofish. Removed preference to Blowfish with - a special hack to suppress the "not listed in preferences" warning; - this is to allow us to switch completely to Twofish in the near future. - - * Changed the locking stuff. - - * Print all user ids of a good signature. - - -Noteworthy changes in version 0.9.2 ------------------------------------ - - * add some additional time warp checks. + * [scdaemon] Overhauled the internal CCID driver. - * Option --keyserver and command --send-keys to utilize HKP servers. + * [scdaemon] Status files named ~/.gnupg/reader_<n>.status are now + written when using the internal CCID driver. - * Upgraded to zlib 1.1.3 and fixed an inflate bug + * [gpgsm] New commands --dump-{,secret,external}-keys to show a very + detailed view of the certificates. - * More cleanup on the cleartext signatures. + * The keybox gets now compressed after 3 hours and ephemeral + stored certificates are deleted after about a day. + * [gpg] Usability fixes for --card-edit. Note, that this has already + been ported back to gnupg-1.3 -Noteworthy changes in version 0.9.1 ------------------------------------ - * Polish language support. - - * When querying the passphrase, the key ID of the primary key is - displayed along with the one of the used secondary key. - - * Fixed a bug occurring when decrypting pgp 5 encrypted messages, - fixed an infinite loop bug in the 3DES code and in the code - which looks for trusted signatures. - - * Fixed a bug in the mpi library which caused signatures not to - compare okay. - - * Rewrote the handling of cleartext signatures; the code is now - better maintainable (I hope so). - - * New status output VALIDSIG only for valid signatures together - with the fingerprint of the signer's key. - - -Noteworthy changes in version 0.9.0 ------------------------------------ - - * --export does now only exports rfc2440 compatible keys; the - old behaviour. - - -Noteworthy changes in version 0.4.5 ------------------------------------ - - * The keyrings and the trustdb is now locked, so that - other GnuPG processes won't damage these files. You - may want to put the option --lock-once into your options file. - - * The latest self-signatures are now used; this enables --import - to see updated preferences etc. - - * Import of subkeys should now work. - - * Random gathering modules may now be loaded as extensions. Add - such a module for most Unices but it is very experimental! - - * Brazilian language support. - - -Noteworthy changes in version 0.4.4 ------------------------------------ - - * Fixed the way the key expiration time is stored. If you have - an expiration time on your key you should fix it with --edit-key - and the command "expire". I apologize for this inconvenience. - - * Add option --charset to support "koi8-r" encoding of user ids. - (Not yet tested). - - * Preferences should now work again. You should run - "gpgm --check-trustdb \*" to rebuild all preferences. - - * Checking of certificates should now work but this needs a lot - of testing. Key validation values are now cached in the - trustdb; they should be recalculated as needed, but you may - use --check-trustdb or --update-trustdb to do this. - - * Spanish translation by Urko Lusa. - - * Patch files are from now on signed. See the man page - for the new option --not-dash-escaped. - - * New syntax: --edit-key <userID> [<commands>] - If you run it without --batch the commands are executed and then - you are put into normal mode unless you use "quit" or "save" as - one of the commands. When in batch mode, the program quits after - the last command, so you have to use "save" if you did some changes. - It does not yet work completely, but may be used to list so the - keys etc. - - -Noteworthy changes in version 0.4.3 ------------------------------------ - - * Fixed the gettext configure bug. - - * Kludge for RSA keys: keyid and length of a RSA key are - correctly reported, but you get an error if you try to use - this key (If you do not have the non-US version). - - *. - - -Noteworthy changes in version 0.4.2 ------------------------------------ - - * This is only a snapshot: There are still a few bugs. - - * Fixed this huge memory leak. - - * Redesigned the trust database: You should run "gpgm --check-trustdb". - New command --update-trustdb, which adds new key from the public - keyring into your trustdb - - * Fixed a bug in the armor code, leading to invalid packet errors. - (a workaround for this was to use --no-armor). The shorten line - length (64 instead of 72) fixes a problem with pgp5 and keyservers. - - * comment packets are not anymore generated. "--export" filters - them out. One Exception: The comment packets in a secret keyring - are still used because they carry the factorization of the public - prime product. - - * --import now only looks for KEYBLOCK headers, so you can now simply - remove the "- " in front of such a header if someone accidently. - - - -Noteworthy changes in version 0.4.1 ------------------------------------ - *. - - -Noteworthy changes in version 0.4.0 ------------------------------------ - *. - - -Noteworthy changes in version 0.3.5 ------------------------------------ - * New option --throw-keyid to create anonymous enciphered messages. - If gpg detects such a message it tires all available secret keys - in turn so decode it. This is a gnupg extension and not in OpenPGP - but it has been discussed there and afaik some products use this - scheme too (Suggested by Nimrod Zimmerman). - - *). - - -Noteworthy changes in version 0.3.4 ------------------------------------ - * New options --comment and --set-filename; see g10/OPTIONS - - * yes/no, y/n localized. - - * Fixed some bugs. - -Noteworthy changes in version 0.3.3 ------------------------------------ - * IMPORTANT: I found yet another bug in the way the secret keys - are encrypted - I did it the way pgp 2.x did it, but OpenPGP - and pgp 5.x specify another (in some aspects simpler) method. - To convert your secret keys you have to do this: - format of the trust database has changed; you must delete - the old one, so gnupg can create a new one. - IMPORTANT: Use version 0.3.[12] to save your assigned ownertrusts - ("gpgm --list-ownertrust >saved-trust"); then build this new version - and restore the ownertrust with this new version - ("gpgm --import-ownertrust saved-trust"). Please note that - --list-ownertrust has been renamed to --export-ownertrust in this - release and it does now only export defined ownertrusts. - - * The command --edit-key now provides a commandline driven menu - which can be used for various tasks. --sign-key is only an - an alias to --edit-key and maybe removed in future: use the - command "sign" of this new menu - you can select which user ids - you want to sign. - - * Alternate user ids can now be created an signed. - - * Owner trust values can now be changed with --edit-key (trust) - - * GNUPG can now run as a coprocess; this enables sophisticated - frontends. tools/shmtest.c is a simple sample implementation. - This needs some more work: all tty_xxx() are to be replaced - by cpr_xxx() and some changes in the display logics is needed. - - *. - - -Noteworthy changes in version 0.3.2 ------------------------------------ - *. - -Noteworthy changes in version 0.3.1 ------------------------------------ - *. - -Noteworthy changes in version 0.3.0 ------------------------------------ - - *. - - -Noteworthy changes in version 0.2.19 ------------------------------------- - - *. - - -Noteworthy changes in version 0.2.18 ------------------------------------- - - * Splitted cipher/random.c, add new option "--disable-dev-random" - to configure to support the development of a random source for - other systems. Prepared sourcefiles rand-unix.c, rand-w32.c - and rand-dummy.c (which is used to allow compilation on systems - without a random source). - - * Fixed a small bug in the key generation (it was possible that 48 bits - of a key were not taken from the random pool) - - * Add key generation for DSA and v4 signatures. - - * Add a function trap_unaligned(), so that a SIGBUS is issued on - Alphas and not the slow emulation code is used. And success: rmd160 - raised a SIGBUS. - - * Enhanced the formatting facility of argparse and changed the use of - \r,\v to @ because gettext does not like it. - - * New option "--compress-algo 1" to allow the creation of compressed - messages which are readable by PGP and "--print-md" (gpgm) to make - speed measurement easier. - - -Noteworthy changes in version 0.2.17 ------------------------------------- - - *. - - -Noteworthy changes in version 0.2.16 ------------------------------------- - - * Add experimental support for the TIGER/192 message digest algorithm. - (But there is only a dummy ASN OID). - - * Standard cipher is now Blowfish with 128 bit key in OpenPGP's CFB - mode. I renamed the old cipher to Blowfish160. Because the OpenPGP - group refused to assign me a number for Blowfish160, I have to - drop support for this in the future. You should use - "--change-passphrase" to recode your current passphrase with 128 - bit Blowfish. - - -Noteworthy changes in version 0.2.15 ------------------------------------- - - * Fixed a bug with the old checksum calculation for secret keys. - If you run the program without --batch, a warning does inform - you if your secret key needs to be converted; simply use - --change-passphrase to recalculate the checksum. Please do this - soon, as the compatible mode will be removed sometime in the future. - - * CAST5 works (using the PGP's special CFB mode). - - * Again somewhat more PGP 5 compatible. - - * Some new test cases - -Noteworthy changes in version 0.2.14 ------------------------------------- - - *. - - -Noteworthy changes in version 0.2.13 ------------------------------------- - - * Verify of DSA signatures works. - - * Re-implemented the slower random number generator. - - -Noteworthy changes in version 0.2.12 ------------------------------------- - - * -. - -Noteworthy changes in version 0.2.11 ------------------------------------- - - *? - -Noteworthy changes in version 0.2.10 ------------------------------------- - - * Code for the alpha is much faster (about 20 times); the data - was misaligned and the kernel traps this, so nearly all time - was used by system to trap the misalignments and to write - syslog messages. Shame on me and thanks to Ralph for - pointing me at this while drinking some beer yesterday. - - * Changed some configure options and add an option - --disable-m-guard to remove the memory checking code - and to compile everything with optimization on. ) +----------------------------------- ------------- - * Changed the name to GNUPG, the binaries are called gpg and gpgm. - You must rename rename the directory "~/.g10" to ~/.gnupg/, rename - {pub,sec}ring.g10 to {pub,sec}ring.gpg, trustdb.g10 to trustdb.gpg - and g10.sig to gnupg.sig. + * gpg-protect-tool gets now installed into libexec as it ought to be. + Cleaned up the build system to better comply with the coding + standards. - * New or changed passphrases are now salted. + * . + * [gpgsm] The pinentry will now present a description of the key for + whom the passphrase is requested. . - * Key generation is much faster now. I fixed this by using not - so strong random number for the primes (this was a bug because the - ElGamal primes are public parameters and it does not make sense - to generate them from strong random). The real secret is the x value - which is still generated from strong (okay: /dev/random) random bits. + * ~/. - * We have secure memory on systems which support mlock(). - It is not complete yet, because we do not have signal handler - which does a cleanup in very case. - We should also check the ulimit for the user in the case - that the admin does not have set a limit on locked pages. + * Removed --run-as-shm-coprocess feature. - * started with internationalization support . + * gpg does now also use libgcrypt, libgpg-error is required . - * The logic to handle the web of trust is now implemented. It is - has some bugs; but I'm going to change the algorithm anyway. - It works by calculating the trustlevel on the fly. It may ask - you to provide trust parameters if the calculated trust probability - is too low. I will write a paper which discusses this new approach. + * Free Software Foundation, Inc. + Copyright 2002, 2003, 2004, 2005, 2006, 2007
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blobdiff;f=NEWS;h=322bcd2f97a771d2bc6c0214f0404a37453149b3;hp=9746e02a7956592ab87080b9e72ddb05e8726931;hb=4631bc8ddf86b3917bf786c315273d8b1c7798e8;hpb=81f64252c08707600e796ef339c055f9ca69654d
CC-MAIN-2019-47
refinedweb
7,427
68.87
110 000 words jobs ...hic on a micro-budget (currently writing the script) 9pgs = 9minutes ...kinerja offisial dengan grafis yang baik, contohnya Ideapad 110-141SK. Siapa Bilang Andalkan AMD Itu Buruk? Begitu melihat ulasan penulis yang mengatakan jika Ideapad-series selalu menggabungkan kinerja offisial dengan grafis yang baik, maka sudah bisa dipastikan didalam harga Ideapad 110-141SK yang dibandrol paling mahal 8 jutaan ini akan ada manuver I need 3 graphics made up for a sports brand website 1. Free Shipping 2. Threadbare Guarantee 3. 110% Returns... Minimilist look white background with dark grey image We will provide you with a list of 18 000 Twitter handles and your job would be to extract and store their tweets in a MongoDB collection. I have approximateley 110 ms word articles each arond 330 words long that need to be made into an ebook for kindle etc The book will need a cover and content page ...realism is very important, as I would want readers to be able to recognise the individuals being depicted. The page size of the book will be the standard British A-format of 110 mm × 178 mm (4.3 in × 7.0 in). You would not necessarily have to create all the art. If you could only create 1 or 2 pieces, I would still be very grateful to hear from you We need a little green man created 3D model (similar to picture attached) Colour is PMS 2300c and it measures 110 x 85mm. The depth will be proportionate to the length and width – the head will be spherical and the arms and legs cylindrical. Hoban logo in position shown on front. 1 000 000 Real Human Visitors to our Website .. ...Critical Analysis Essay: (3,000 – 3,500 words) The Essay statement and Question: Human resource management policies and practices significantly influence the psychological contract by signalling to employees the expectations of the organisation as well as what employees can expect in return (Holland et al. 2012, p. 110) Given the mobility of workers and Ho bisogno che un sito web venga sistemato Hi I want 1st 2nd position on [url removed, login to view] [url removed, login to view] searching for escort + " all Italian cities" which are 110 . I need result in 2 month or the payment will be lower . The web site is done with php my SQL . And I want some adjustments to ultimate the website. Create new site from old, please make look good, thanks. Budget: $110 We need writers to review websites and write a snippet (short description) about t...if you have the skills and quality there will be plenty of work available for you We pay 50c per 110-120 word snippet. I need atleast 3K words on a daily basis. I'll hire 2 writers. *BIDS WITHOUT A SAMPLE ON INTERNET MARKETING OF 200 WORDS WILL BE IGNORED* I'm looking for an AC-AC Converter with a regulated output voltage of 110 VAC for a Universal Input in the range of 80-300 VAC.
https://www.freelancer.com/job-search/110-000-words/
CC-MAIN-2017-34
refinedweb
507
70.53
Created on 2010-08-04 22:50 by pitrou, last changed 2016-05-20 18:20 by BreamoreBoy.. (The email daemon was not in a happy place, so posting directly) On Thu, Aug 5, 2010 at 8:50 AM, Antoine Pitrou <report@bugs.python.org> wrote: > - perhaps improve the existing functions (kill_python() does a strange dance instead of calling communicate() on the subprocess.Popen object, is there a reason for that?) script_helper just factored out the old test_cmd_line approach which was in turn based on a minimalistic change from a popen2 based implementation (see). Doing something smarter probably isn't a bad idea. One other feature for the new-and-improved helpers: add a flag to allow "-E" to be omitted (as per the comment in test_cmd_line) I still think this is a good idea, I'm just not actively working on it. It might make a good project for someone wanting to get to know the process of working on CPython without having to deal with anything that is particularly tricky to understand. > someone wanting to get to know the process of working on CPython without having to deal with anything that is particularly tricky to understand. That sounds exactly like me :) I can have a look at this ticket. I just tried using script_helper in a new test, so I have a couple of comments. I don't see stdout and stderr being conflated, it looks to me like they are returned separately, at least by the assert methods. The assert methods return results, which is unlike other assert methods. This is very useful, even essential, and I wouldn't want to give it up. That conflicts with the current unittest conventions, though. It would be a big help if 'err' were returned with the refcount line removed if it is there, which would make tests using the methods return the same 'err' regardless of whether they are run under a debug build or not. I think the names of the two assert functions should follow the current unit test conventions (assertPythonRunOK and asssertPythonRunNotOK, perhaps?) > I just tried using script_helper in a new test, so I have a couple of > > I don't see stdout and stderr being conflated, it looks to me like > they are returned separately, at least by the assert methods. That's because I wrote the assert methods since this issue was opened :) > It would be a big help if 'err' were returned with the refcount line > removed if it is there, which would make tests using the methods > return the same 'err' regardless of whether they are run under a debug > build or not. Indeed. > I think the names of the two assert functions should follow the > current unit test conventions (assertPythonRunOK and > asssertPythonRunNotOK, perhaps?) Well, they are functions, not methods, so I don't think they have to follow the other convention. OK,...) Here is a patch that causes _assert_python to remove the refcount lines from stderr. Hmm. Having posted that it occurs to me that it could be useful to have the _remove_refcount function in test.support as remove_refcount instead. > Having posted that it occurs to me that it could be useful to have the > _remove_refcount function in test.support There's already strip_python_stderr() :) Oh, good, I'll use that then. I could have sworn I looked for that functionality a couple weeks ago and couldn't find it. > There's already strip_python_stderr() :) This is already used in Lib/test/script_helper.py:42, and a way to call _assert_python() without using -E has also been introduced[0]. The next step would be to check if these functions could be used elsewhere in the other tests. Also note that these functions are not currently documented anywhere. [0]: @Rodrigue did you ever make any progress with this? @Mark, I had a look at the time I commented on the ticket but didn't get a chance to progress much in the end. Script helpers has been "made more discoverable" by moving it into the test.support namespace, but it has not been documented in the test.support docs. I can no longer remember if this is intentional or not. Regardless, this issue is still valid insofar as there are probably a number of places in the test suite where script_helpers can be used that they aren't being used. We probably don't want a multi-module changeset, though, so this could become a meta issue for new issues for converting particular test files to use script_helpers. Hello @r.david.murray! > We probably don't want a multi-module changeset, though, so this could become a meta issue for new issues for converting particular test files to use script_helpers. Does this mean you'd like to leave this issue open until all of the test files are updated in separate issues? Or is it that you'd like separate changesets for each module, but all associated with this issue? Thanks! It could be done either way, but I suspect that indovidual issues for test module changes, entered as dependencies on this issue, is probably the more effective in this case. Okay thanks @r.david.murray, I'll take a look at doing this. I'll open an issue when I figure out which module to start on. Apparently I was imaginig that script_helpers had been moved into test.support. test.support was changed into a module in prep for doing so, but as far as I can see it was never moved. So that does remain to be done as well, and should be done first. Okee dokee, I'll tackle that first! I have a patch for moving script_helper as R. David suggested. Here it is. bobcatfish: Sorry, I didn't refresh and see your comment before submitting my patch. It only moves script_helpers, but doesn't address the original OP. Hopefully I made your life easier, not harder. re: test.test_tools.py - should this also move into test.support ? test_tools is a test suite that tests the tools in the scripts directory, it is not tools for testing. So no, it doesn't belong in test.support. Hey there @flipmcf, is the change which adds `script_helpers` to test.support is missing from your patch? >>> import test.support.script_helper Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'test.support.script_helper' I'm thinking also, maybe instead of putting script_helper into the test.support namespace, we could move the individual methods and helpers from script_helper into test.support, e.g.: test.support.run_python_until_end vs. test.support.script_helper.run_python_until_end Yes, I did miss that. (Root cause: `git diff` instead of `git diff --staging`) Sorry. I'm learning, and decided to take the git path - might not have been the best choice. I'll submit a new patch shortly. > I'm thinking also, maybe instead of putting script_helper into the > test.support namespace, we could move the individual methods and > helpers from script_helper into test.support, e.g.: > > test.support.run_python_until_end > vs. > test.support.script_helper.run_python_until_end1 Yes, I also agree that this looks better. But as this was first humble patch submission to CPython, I followed David Murry's instructions during my review - which was to move the entire module. I would be opposed to adding the methods directly into __init__.py, I would recommend still moving script_helper into test.support , and adding a list of symbols from script_helper.py into __init__ eg: test/support/__init__.py: from script_helper import run_python_until_end test/some_test.py: from test.support import run_python_until_end I am currently in the PyCon CPython sprint room if you are also here. Uploading new patch that includes the creation of Lib/test/support/script_helper.py > I would recommend still moving script_helper into test.support , and adding a list of symbols from script_helper.py into __init__ Sounds like a great plan to me @flipmcf! I actually originally wanted to do just that (move the script helpers routine into the old support.py) but I was in the minority. test.support was turned into a package exactly so that script_helpers could become a sub-namespace. As I remember, it was Nick Coghlan who championed the sub-namespace position :) namespaces are a honkin' great idea I don't have enough information to say that 'script_helper' is the right name for the namespace, tho. @r.david.murray and @flipmcf: I've audited all test modules using sys.executable for a starting point, and these tests look like they could benefit from helper methods to invoke python (probably the ones in script_helper, but we may want to create others if the use cases don’t quite fit): * _test_multiprocessing.py * test_base64.py * test_capi.py - some of this looks legitimate, but some of it could maybe benefit from the helpers * test_cmd_line.py * test_faulthandler.py * test_file_eintr.py * test_gc.py * test_keyword.py * test_pdb.py * test_popen.py * test_quopri.py * test_site.py * test_source_encoding.py * test_sys.py * test_sysconfig.py * test_tcl.py - something complex is going on in here, not sure if it’s necessary or not * test_threading.py * test_pindent.py * test_traceback.py * test_unicodedata.py * test_json/test_tool.py @r.david.murray I'm going to start with test_unicodedata.py for a nice easy starting point so I'll create a separate issue for it. @flipmcf should I start using your patch set as-is or is there more to come? @Christie - Nope. This patch can stand on it's own, simply moving the package to where it belongs. In fact, I'd recommend applying the patch first. So @flipmcf we're sticking with the test.support.script_helper namespace? Alternatively, you can import public functions from support/script_helper.py in support/__init__.py. Then you can do from test.support import assert_python_ok Reviewing iss9517_move_script_helpers_py.patch: * Can you move script_helper.py by using "hg mv"? @r.david.murray I've created issue23981, I don't think I have permissions to add it as a dependency to this issue. Hey @berker.peksag, @r.david.murray! Here's another change set where script_helpers.py is moved with an hg mv (still looks in the patch like the file was deleted and re-added, not sure if that's expected). I've ALSO removed some unused imports from script_helpers.py - temp_dir was being imported from script_helpers in a few places tho, so I had to fix that. If you guys would rather not include that change here, please let me know! Created issue24033. If it and issue23981 could be added as dependencies of this issue (or I could get permission to add them?) that would be swell! Thanks for the patch, Christie. Review comments: > (still looks in the patch like the file was deleted and re-added, not sure if that's expected). I don't know if it's important. I'm using a very old version of Mercurial (2.0.2 :)), so it can be related to different Mercurial versions. Attaching a patch for reference. You should create the patch with "hg diff --git" to preserve moving. And then apply it with "hg import", not the patch command. Unfortunately Rietveld don't like patches in git format. Hey @berker.peksag, I've added a new patch in response to your review! > You should create the patch with "hg diff --git" to preserve moving. And then apply it with "hg import", not the patch command. Unfortunately Rietveld don't like patches in git format. Ick, I'm guessing it's okay to just use plain old "hg diff" then, if Rietveld doesn't like the patches in git format. The committer should be careful, and manually make "hg mv" and apply the patch with the patch command, not "hg import". We shouldn't lost the history. @serhiy.storchaka - just double checking, do you guys need me to make any more changes to the patch? And is there any more review needed, or is it possible for this to be merged? Thanks very much! New changeset f65174aef9ea by Berker Peksag in branch 'default': Issue #9517: Move script_helper to the support package. Thanks very much @berker.peksag! Hey @berker.peksag, @r.david.murray, @serhiy.storchaka, If you get a chance I've got some changes up for review at: * * Thanks! Just noting that issue 18576 has a draft patch for test.support.script_helper documentation (the "move to the support module" part of the current patch there is obsolete) Cool, thanks @ncoghlan! Would you like someone to take on the work of updating the latest patch on issue 18576? Sure, that would be great. Created Issue24279 for updating test_base64. Created issue24398 for updating test_capi. Hello all! So the following are waiting for review: * #24033 * #23981 * #24279 I'm going to hold off on continuing to refactor any other modules for the moment, would be great to get the above wrapped up and eventually merged when possible. Thanks! - Christie Berker committed the original patch to move the helper module, so adjusting the stage back to reflect the ongoing review on related issues.
http://bugs.python.org/issue9517
CC-MAIN-2016-44
refinedweb
2,164
65.52
Casting a proxy to the most derived interface in Help Center I have an hierarchy of interfaces: Now, if there was a method which cast a proxy to its actual type, I could write I could write it using reflection (error checking omitted): interface I1 {...} interface I2 extends I1 {...} interface I3 extends I1 {...}and I need to do something with a proxy which depends on the type of object (not the static type). That is, ObjectPrx prx = ... I1Prx i1 = I1PrxHelper.checkedCast(prx); if (i1 != null) then ... I2Prx i2 = I2PrxHelper.checkedCast(prx); if (i2 != null) ... I3Prx i1 = I3PrxHelper.checkedCast(prx); if (i3 != null) ...However, the above requires a lot of remote calls and 2 more will be added each time a new interface is introduced. Now, if there was a method which cast a proxy to its actual type, I could write ObjectPrx precisePrx = castToActualType(prx); if (precisePrx instanceOf I1Prx) ... if (precisePrx instanceOf I2Prx) ... if (precisePrx instanceOf I3Prx) ... I could write it using reflection (error checking omitted): ObjectPrx castToActualType(ObjectPrx prx) { String type_id = prx.ice_id(); String prxInterfaceName = type_id.substring(2).replaceAll("::", ".") ++ "Prx"; String helperName = prxInterfaceName ++ "Helper"; Class<?> klass = Class.forName(helperName); Method castMethod = klass.getMethod("checkedCast"); return (ObjectPrx) castMethod.invoke(null, prx); }Is there a simpler way to do it? Or an explanation why this is a bad idea? 0 I would go with the following option: Note that it's a bit unfortunate that you have to use the generated _<interface name>Disp type here to get the type ID, it would be nicer if ice_staticId() was a static operation of the PrxHelper class, we'll discuss adding this. One issue with your solution that uses reflection is that it assumes that the Slice type ID maps to an equivalent Java class name. This might not always be the case if the [noparse]"java:package:com.foo"[/noparse] metadata is used in the Slice to generate the Java classes in a given package. Cheers, Benoit. That being said, such checks usually indicate that you're not taking advantage of polymorphism. Why are you checking for the type of the proxies? Is it to call some specific methods on the proxies afterwards? Perhaps you can add a method on the base interface to simplify this code? Cheers, Benoit. This way, you can retrieve all the properties with a single request and you can check for the type of the result of getInfo() to display the properties of each object: Cheers, Benoit. Cheers, Benoit.
https://forums.zeroc.com/discussion/comment/34045/
CC-MAIN-2022-33
refinedweb
413
67.35
Up to [cvs.NetBSD.org] / src / include Request diff between arbitrary revisions Default branch: MAIN Revision 1.12.50.1 / (download) - annotate - [select for diffs], Tue Feb 8 16:18:55 2011 UTC (4 years, 9 months ago) by bouyer Branch: bouyer-quota2 Changes since 1.12: +2 -1 lines Diff to previous 1.12 (colored) next main 1.13 (colored) Sync with HEAD Revision 1.13 / (download) - annotate - [select for diffs], Mon Jan 31 04:49:46 2011, uebayasi-xip-base, agc-symver-base, agc-symver, HEAD Changes since 1.12: +2 -1 lines Diff to previous 1.12 (colored) new error. Revision 1.12 / (download) - annotate - [select for diffs], Thu Feb 3 04:39:32 2005 UTC (10 years, 9: bouyer-quota2 Changes since 1.11: +2 -2 lines Diff to previous 1.11 (colored) de-__P -- the hack is long since useless. Discussed with christos, matt, kleink, others. Approved by christos. Revision 1.11 / (download) - annotate - [select for diffs], Thu Aug 7 09:44:10 2003 UTC (12 years,: +2 -6 lines Diff to previous 1.10 (colored) Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22270, verified by myself. Revision 1.10 / (download) - annotate - [select for diffs], Mon Apr 28 23:16:13 2003 UTC (12 years, 7 months ago) by bjh21 Branch: MAIN Changes since 1.9: +2 -2 lines Diff to previous 1.9 (colored) Add a new feature-test macro, _NETBSD_SOURCE. If this is defined by the application, all NetBSD interfaces are made visible, even if some other feature-test macro (like _POSIX_C_SOURCE) is defined. <sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE, _POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve existing behaviour. This has two major advantages: + Programs that require non-POSIX facilities but define _POSIX_C_SOURCE can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS. + It makes most of the #ifs simpler, in that they're all now ORs of the various macros, rather than having checks for (!defined(_ANSI_SOURCE) || !defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place. I've tried not to change the semantics of the headers in any case where _NETBSD_SOURCE wasn't defined, but there were some places where the current semantics were clearly mad, and retaining them was harder than correcting them. In particular, I've mostly normalised things so that _ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE, _XOPEN_SOURCE and _NETBSD_SOURCE in that order. Tested by building for vax, encouraged by thorpej, and uncontested in tech-userlevel for a week. Revision 1.7.2.2 / (download) - annotate - [select for diffs], Fri Oct 18 02:14:39 2002 UTC (13 years, 1 month ago) by nathanw Branch: nathanw_sa CVS Tags: nathanw_sa_end Changes since 1.7.2.1: +2 -1 lines Diff to previous 1.7.2.1 (colored) next main 1.8 (colored) Catch up to -current. Revision 1.9 / (download) - annotate - [select for diffs], Sun Oct 6 03:15:45 2002 UTC (13 years, 1 month ago) by provos Branch: MAIN CVS Tags: nathanw_sa_before_merge, nathanw_sa_base, fvdl_fs64_base Changes since 1.8: +2 -1 lines Diff to previous 1.8 (colored) implement FNM_LEADING_DIR; matches Linux and other *BSDs; approved thorpej Revision 1.7.2.1 / (download) - annotate - [select for diffs], Wed Nov 14 19:32:34 2001 UTC (14 years ago) by nathanw Branch: nathanw_sa Changes since 1.7: +2 -2 lines Diff to previous 1.7 (colored) Catch up to -current. Revision 1.8 / (download) - annotate - [select for diffs], Sat Oct 27 15:41:18 2001 UTC (14 years, 1 month) Make FNM_CASEFOLD !_XOPEN_SOURCE, too. Revision 1.6.10.1 / (download) - annotate - [select for diffs], Mon Jul 3 22:29:20 2000 UTC (15 years,.6: +6 -1 lines Diff to previous 1.6 (colored) next main 1.7 (colored) Pull up rev. 1.7: Implement FNM_CASEFOLD, for matching the pattern in a case-insensitive way. Flag name taken from glibc. Revision 1.7 / (download) - annotate - [select for diffs], Wed Jun 28 01:13:35 2000 UTC (15 years, 5 months ago) by thorpej Branch: MAIN Branch point for: nathanw_sa Changes since 1.6: +6 -1 lines Diff to previous 1.6 (colored) Implement FNM_CASEFOLD, for matching the pattern in a case-insensitive way. Flag name taken from glibc. Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Mon Feb 2 07:23:23 1998 UTC (17 years, 9 months ago) by perry Branch: CSRG CVS Tags: lite-2 Changes since 1.1: +8 -6 lines Diff to previous 1.1 (colored) import lite-2 Revision 1.6 / (download) - annotate - [select for diffs], Tue Jan 13 12:45:02 1998 UTC (17 years, 10 months ago) by kleink: netbsd-1-5 Changes since 1.5: +2 -1 lines Diff to previous 1.5 (colored) Add a FNM_NOSYS return code. This condition will never happen (since fnmatch() is implemented), but this preprocessor symbol is required by XPG4.2. Revision 1.5 / (download) - annotate - [select for diffs], Wed Oct 26 00:55:53 1994 UTC (21.4: +3 -2 lines Diff to previous 1.4 (colored) new RCS ID format. Revision 1.4 / (download) - annotate - [select for diffs], Thu Nov 11 03:25:48 1993 UTC : +1 -3 lines Diff to previous 1.3 (colored) Remove #ifdefs introduced in last change -- the <fnmatch.h> header is not specified by 1003.1, so any program that includes it is automatically not POSIX.1 compliant. Revision 1.3 / (download) - annotate - [select for diffs], Sat Nov 6 00:58:17 1993 UTC (22 years ago) by cgd Branch: MAIN Changes since 1.2: +9 -7 lines Diff to previous 1.2 (colored) update to latest version; don't proto fnmatch() unless _POSIX_SOURCE not defined. Revision 1.2 / (download) - annotate - [select for diffs], Sun Aug 1 18:45:03 1993 UTC (22 years, 3 months ago) by mycroft Branch: MAIN Changes since 1.1: +2 -1 lines Diff to previous 1.1 (colored) Add RCS identifiers. Revision 1.1 / (download) - annotate - [select for diffs], Wed Jun 16 17:17:30 1993 UTC (22 years, 5 months ago) by jtc Branch: MAIN CVS Tags: netbsd-0-9-base, netbsd-0-9-RELEASE, netbsd-0-9-BETA, netbsd-0-9-ALPHA2, netbsd-0-9-ALPHA, netbsd-0-9 Update fnmatch to be more posix complient (from keith bostic) This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.
http://cvsweb.netbsd.org/bsdweb.cgi/src/include/fnmatch.h
CC-MAIN-2015-48
refinedweb
1,101
66.44
Fire Emblem: Radiant Dawn "The Radiant Dawn of the future of Fire Emblem is here!" The tenth game in the series, the eagerly anticipated Radiant Dawn, has arrived. It follows the traditional Fire Emblem formulae, while managing to spice things up and shake the player's thoughts around. A direct sequel to the Gamecube's acclaimed Path of Radiance, the story begins three years after the first game... and Radiant Dawn improves on its predecessor in just about every way. Path of Radiance's story was mostly completed by its ending, but the ending left a few things hanging up in the air. Radiant Dawn seizes on many of those things, eventually providing a rich history of the continent of Tellius. The story starts off in the occupied country of Daein, where the Begnion troops stationed there are committing grave offenses and getting away with it. Enter the Dawn Brigade: five residents of the capital city of Nevassa who are devoted to doing good deeds and helping out the oppressed poor of the city. Micaiah, their leader and a major character in the game, is a young woman who can randomly see the future. However, her striking silver hair gives her away easily, and the Dawn Brigade has to leave Nevassa... then the game truly begins, after two chapters in the city. Strings are yanked on, unraveling secret after secret, exposing the tortured history of Tellius and why things happened as they did. Also, every single playable character - save two - from Path of Radiance returns and has a role in the story. As for the two who don't return, one looks exactly like another character, and the other one shows up in a conversation or two. On the topic of characters, Radiant Dawn almost overdoes it. Seventy-three characters can be recruited or controlled over the course of the game, with two of them only available in repeat playthroughs, and a third unavailable for the final chapter. Even with all the returning favorite characters from Path of Radiance, numbering around fifty, there are standouts among the new arrivals. Early on, Edward the Myrmidon - a speedy sword-user - is a lifesaver. Later, Volug the Wolf - a laguz who can remain in wolf form at the cost of 1/4 of his stats, which isn't much of a loss - becomes a star with his wide movement range and powerful fangs. Supports have been redone as well, with practically any character able to support with any other. The only downside to that is that most in-battle Support conversations (thankfully optional for increasing the Support level) are rather generic in-character statements, but a few of the lines are quite a laugh to read. Which brings me back around to the writing and dialogue. The story exists to tie the battles together, but said story is exceedingly well-written. Confusion is also easily alleviated by the fact that from the pre-battle menu, lists of characters and important terms are accessible for reminders on what's what and who's who. Sure, there are a few mistakes in there, such as Mist's profile showing up for both Mist and Muarim, or the term "Fire Emblem" being translated as "Heart of Fire", but with the sheer amount of text in the game, and the fact that it has to be interesting and engaging on top of being well-translated makes the occasional typo (I spotted at least four) well within normal bounds and probably even into the realm of top-notch proofreading. The controls are literally as simple as they come. Hold the Wiimote so the Control Pad is in your left hand and the 1 and 2 buttons in your right hand, and the game pretty much has the controls displayed on the bottom of the screen at most times. No motion control is implemented, but really, the game doesn't need it one bit. Only rarely do I press the wrong button, and it almost never has an adverse effect on my playing. Graphics. The graphics are basically the same as in Path of Radiance, only polished up greatly. Literally the only areas where I can clearly see edges of polygons are on the hems of flying capes and some bending wings while flying characters are waiting around on the battle map. There are also twice as many FMV scenes as in Path of Radiance, with each one looking as stunning as the next. There is some realism incorporated into those scenes, but the anime inspiration is very clear. In-battle graphics are upgraded considerably, with each unit type having more animations, as well as each character having a third level of classes to promote to, meaning more models per character, as each class has its own "look" - the characters are also more distinct this time, with fewer helmets and more facial detail (Calill's elegant hair and Haar's eyepatch are great examples here). That extra class means 20 more levels are available for each character: yes, that's right, beorc can reach the equivalent of Level 60, while laguz can now go up to Level 40. Another wonderful bonus is that meeting a character, or in some cases just hearing about them, unlocks a piece of official art depicting the character for view anytime. With 85 pieces in all, there are naturally several that will be frustrating to obtain - Stefan's in particular. The only little thing is that large numbers of characters in a menu at once cause noticeable slowdown, but there is really only a single situation where that actually happens. Music is important as well. Some familiar themes return, such as the royal themes and the recruitment theme, while some new characters have wonderful themes as well. Even if the music ends up taking a far backseat to the action, the music almost always fits the mood or the setting. Fire Emblem as a series is known for its gameplay quirks. When a character is defeated in battle, if they were on the Player (blue) team, they are dead and cannot return (with a few exceptions - some characters just retreat and are unusable though they remain alive). If your "commander" dies (varies by which chapter you're playing), it's Game Over. The two characters that will always create a Game Over with their deaths are Ike and Micaiah. Sothe and Elincia are frequently in that category as well - the first couple chapters even require you to keep everyone alive or it's a game over. MIcaiah is especially frail, with very low health and defense, so she must be protected... yet she must also acquire combat experience if she is to be of any use. That's the strategy of the game: placing characters on the grid so they won't die, but have a good chance to gain experience and get stronger. The final quirk only comes into play in a major way for the final chapter, but given the number of characters in the game, it's tougher than ever. That quirk is that most chapters do not allow you to use all of your characters - you must pick and choose wisely, or you might have all your flying characters in a sea of archers, which is a recipe for losing your flyers. The quirk is slightly remedied by the game's story constantly switching perspectives from one group of characters to another to a third... occasionally intersecting, sometimes even opposing! Thankfully, any character defeated while on the green Other or red Enemy teams, if previously recruited, will have the smarts to retreat and heal up to continue being playable... unless said character is one of the ones whose death triggers a game over on that chapter. Expect to restart chapters NUMEROUS times - thankfully there's a "Battle Save" that allows you to save during your turn and return to that point. Some chapters really do require the use of that new feature on every one of your turns, as four or five battles have your team more than outclassed by the enemies, and one of them literally requires dumb luck to survive with everyone alive. I think that's everything... wait. Path of Radiance savefiles can be imported from a GCN memory card and used to power up characters that hit Level 20 in that game. Support levels are also carried over in some form - ONE of them, if at A level and repeated in this game, will unlock a purely optional conversation before the final battle. However, I believe that its secritiveness will cause it to be very revealing about the characters involved and the true bond of friendship they share. Okay, now that's everything. This game cannot be completed in a rental - I only finished it a few hours ago, after buying it on November 6th. That's fifteen days... forty-three maps to complete truly is a lot, especially as the later maps can take almost two hours EACH to complete. For fans of strategy/tactical games and RPGs, this is truly the Radiant Dawn for you. The difficulty level, even on Easy, is quite unforgiving, but that Reset button is your friend, as are all the characters... I grew to care about enough of them that some of the bosses were almost tragic to kill. Amusingly, Radiant Dawn does an excellent job explaining why the subtitles of both Path of Radiance and Radiant Dawn make perfect sense... in the Japanese subtitles: Path of Blue Flames and Goddess of Dawn. Reviewer's Rating: 5.0 - Flawless Originally Posted: 11/21/07 Game Release: Fire Emblem: Radiant Dawn (US, 11/05/07) Got Your Own Opinion? Submit a review and let your voice be heard.
http://www.gamefaqs.com/wii/932999-fire-emblem-radiant-dawn/reviews/120013
CC-MAIN-2016-50
refinedweb
1,628
58.21
After compiling this code, I am getting a "cannot find symbol constructor Timer(int,Morning)" on line 17. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Morning extends JFrame { private EasySound rooster; private int time; /** * Constructor */ public Morning (int time) { time = 0; Timer clock = new Timer(30, this); clock.start(); } public Morning() { super("Morning"); rooster = new EasySound("roost.wav"); rooster.play(); Container c = getContentPane(); c.setBackground(Color.WHITE); } public static void main(String[] args) { Morning morning = new Morning(); morning.setSize(300, 150); morning.setDefaultCloseOperation(EXIT_ON_CLOSE); morning.setVisible(true); } } Because the class "Timer" constructor prototype doesn't have the type you are declaring. Where is your Timer class? And what are its constructors? // do you have this type of constructor in your Timer class? public Timer(int anInt, Morning aMonringObj) { ... } The second parameter to the Timer constructor you're using needs to implement ActionListener . JFrame doesn't implement it, so you'll have to do that in your Morning class yourself. Also: You'll get better results posting questions like this in the Java forum. The problem is, I don't know what to put in place of super("Morning"). Does anyone know what that means. -From our computer to yours- zach&kody Which Timer class do you really want to use? Is it from javax.swing.Timer, java.util.Timer, or your own customized class? You may need to look at the classes' constructor. They are different. By the way, implementing only ActionListener() inside the Morning class won't solve the whole problem if you still pass in the "Morning" class to the Timer as it is now. i love you zach
http://www.daniweb.com/software-development/java/threads/385723/error-cannot-find-symbol-constructor
CC-MAIN-2014-15
refinedweb
276
60.92
The Scenario: Make an ATL based class library that can be used from both an ATL based console application and an MFC/ATL based GUI application. The class library cannot contain any MFC links. The GUI application must use ATL. The console application may not use any MFC, or link to any library that does. Ok, that sounds like a pretty easy order, but if your not used to playing with some linker settings, you'll get tripped up fast. You could always go the easy route by adding /FORCE:MULTIPLE in the linker command line options, but then every time you compile you will get treated to tons of linker warnings. This is not the way to the shining path! Our goal is to make a well behaved library that will link up without any special options specified in the consuming applications, other than importing the library, and including the header file. /FORCE:MULTIPLE I'm going to call any application that links to a library a consumer. Consumers will #include the library header, and then link to the library file in thier linker stage. In the sample, ConsoleApp, and Application are both consumers. If you compile the sample project with the configuration setting set to "Errors Galore" (Fig 0), you will be treated to loads of nasty looking error messages. LNK2005, LNK2019, LNK4098, LNK1169, LNK1120 Let's start with everyone's least favorite, the often seen LNK4098. This error hangs out with LNK2005. You can fix both by setting your linker options for the library to match the most restricted application that will use your library. In this case, the MFC GUI application demands that it be linked with the Multi-Threaded DLL. If you are compiling in a debug setting, you must link with Multi-Threaded Debug DLL (See Fig1). Once you set this option for your library and recompile it, you will see LNK4098 and LNK2005 beat a hasty retreat. Because you are also going to use this library with an ATL console application, you must set Runtime Library to Multi-Threaded DLL for console application as well. NOTE: If you have other libraries that you are using that expose function signatures similar to the ones in your library, then you may still get LNK2005 errors. Find the offending library, and remove it from your project. If it's a default library, and you are sure you won't need it, you can add it to the Ignore Default Library list (See Fig2). Now, you can try to recompile the sample in the " Less Errors " configuration, and see that we have successfully banished LNK4098 and LNK2005. You will immediately notice that we still haven't gotten rid of an LNK2019 and LNK1120 error. What is really curious about this is that the ConsoleApp linked just fine to the library, and the call from ConsoleApp to the library is the same as the call from Application to the library. What's happening here is under the hood in atlstr.h, the header that contains the ATL definition for CString. The definition for CString in VC++ 7 is radically different from the VC++ 6 one in that it is a template class, where the VC++ 6 implementation is just a class. The problem is that MFC's CString default template is different than the one that ATL is using. What we need to do is to get both the library and the consumer application to use the same signature for the linker. Then, the linker can find the signature in the library at link time, and you won't get those nasty LNK2019 and LNK1120 errors. ConsoleApp CString CString MFC defines CString as: typedef ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > > CString; While ATL defines CString as (With _ATL_CSTRING_NO_CRT defined.): _ATL_CSTRING_NO_CRT typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CString; This difference in the StrTrait is where all the problems with LNK2019 and LNK1120 come from. StrTrait The solution I'm going to use came from this MSDN article, which shows a similar tactic, but unfortunately the method on MSDN makes the library link to MFC, and we don't want that for our ATL library. What I am going to do instead is to change the function in the library to use CAtlString instead of CString in the method calls. If you look at the definition for CAtlString, you will notice that it is just a #define for CStringT, with a specific template. Because CAtlString explicitly states the signature for the parameter, this enables the linker to find the function in the library because it is looking for a function with parameters of type CStringT< TCHAR, StrTraitATL< TCHAR > >. CAtlString CAtlString CStringT CStringT< TCHAR, StrTraitATL< TCHAR > > Also, I am including atlstr.h in the library's header file. This way, when the header file is included in a consumer application, CAtlString will be defined for the header file, and you won't get undefined symbols linker errors for CAtlString. This also ensures that the consumer application doesn't need any funky configuration changes; just include and go! To see the application link up correctly, change the configuration to "Debug" or "Release" and compile it. Because there are 3 individual projects in the attached sample and they are mostly in default state, I am not going to cover them in any great detail. Let's hit the highlights, and see the source code for other miscellenous comments. #pragma once // Include this here, so that any consumer code will automatically import // atlstr so that StrTraitATL will be defined for this header. #include <ATLSTR.H> class CHelloLib { public: CHelloLib(void); ~CHelloLib(void); #ifndef _ERRORS_GALORE // By specifying CAtlString as the parameter token, the linker will // know to use the right ATL version of CStringT, and thus find this // function's signature. void HelloWorld(CAtlString message); #else // Cause LNK2019 by letting the linker try to guess which CStringT // template to use to resolve this function signature. The linker // will try to select the MFC version by default, and not find this // function in the library. This causes the LNK2019. void HelloWorld(CString message); #endif }; Above, we see the source for the library include file. When included in a consumer application, this file will include atlstr.h, so that CAtlString is defined. // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once#define WIN32_LEAN_AND_MEAN //Exclude rarely-used stuff from // Windows headers // TODO: reference additional headers your program requires here #include <atlbase.h> #include <atlstr.h> // Define CAtlString as CString so that the IDE will show the intellesense // for CString instead of showing nothing for CAtlString. CAtlString will // still be used in library generation so that the right linking can be done. #define CAtlString CString Here is the stdafx.h for the Library. You should note at the bottom that I am defining CAtlString to a CString. This may seem counter productive, as in the HelloLib.h header, I just changed all the CString's to CAtlString's! However, without this #define, the intellisense doesn't seem to want to display the quick pick function list that I love so much. Thus, by casting this in stdafx.h for the library (and only the library), intellesense is enabled. When the library compiles, the compiles automatically selects the proper CStringT definition for ATL, as this is an ATL based project. I placed this #define in stdafx.h so that it would not be included in the library header file that will be used by a consumer. This way, the CAtlString declarations are in full effect when the consumer includes the library. CStringT Above, the code for ConsoleApp.cpp, shows you how to select between a debug edition of an included library, and a release version of an included library. I found this to be a quite handy trick, as it instructs the linker to bring in a library without having to adjust the project settings at all! The Application demo also uses the same trick, so I won't bother to put it in here. I think that it's kind of an issue with ATL/MFC as they are technologies that can be mixed together, they should also be able to work around each other. The above solution is rather hacky, even tho it gets the job done simply. I would rather have ATL or MFC check to see if one or the other is included, and use the proper signature, but maybe that could be a goal for VC++ 8... 4/11/2003 - Initial creation / Shining path walk. 4/15/2003 - Not as smart as I thought I was / Path suddenly went dim... Had to change several things to keep from redefining CString in MFC applications when importing the library headers. Path is now back in.
https://www.codeproject.com/Articles/4072/Linker-Errors-CString-ATL-MFC-and-YOU?fid=15354&df=90&mpp=10&sort=Position&spc=None&tid=4155064
CC-MAIN-2018-13
refinedweb
1,471
70.13
Drawing Chessboards I wanted a picture of a chessboard. Rather than boot up some drawing software and cut and paste black and white squares I decided to write a program to create the picture. If you’d like to know why anyone would ever create work for themselves in this way, skip to the end of this article, where you’ll find justification and a more challenging follow-on problem. Otherwise, please read on from top to bottom in the usual way. The Python Imaging Library Fredrik Lundh’s Python Imaging Library (commonly known as PIL) must surely rank as one of the most popular Python libraries which doesn’t come as standard1. It’s a fabulous tool which I’ve used to create the graphic above (though note that the double border around this graphic and subsequent ones is applied by a CSS style property). Here’s how. def draw_chessboard(n=8, pixel_width=200): "Draw an n x n chessboard using PIL." import Image, ImageDraw from itertools import cycle def sq_start(i): "Return the x/y start coord of the square at column/row i." return i * pixel_width / n def square(i, j): "Return the square corners, suitable for use in PIL drawings" return map(sq_start, [i, j, i + 1, j + 1]) image = Image.new("L", (pixel_width, pixel_width)) draw_square = ImageDraw.Draw(image).rectangle squares = (square(i, j) for i_start, j in zip(cycle((0, 1)), range(n)) for i in range(i_start, n, 2)) for sq in squares: draw_square(sq, fill='white') image.save("chessboard-pil.png") Note: - We don’t draw any black squares, instead relying on the default image background being black. - The “L” image type (Luminance?) specifies a greyscale image. - PIL adopts the usual raster graphics convention, of the origin being in the top-left corner. - As we progress down the board row by row, the first white square alternates between being the first and second square of each row. Itertools.cycle((0, 1))achieves this nicely. - A regular 8 x 8 chessboard will, then, have a black square at the bottom left, which is the usual convention. For odd values of n the bottom-left square would be white. - There may be rounding problems with this code if the supplied pixel width isn’t an integral multiple of n. It’s probably better to guarantee the image size, rather than round down the board size. - It would be better to parametrise the output file name, or even return the created image to clients. For now, we’ll just save to a fixed-name PNG. ImageMagick PIL is a general purpose image processing library and it takes a little head-scratching and maths before we can even create something as simple as a chessboard. ImageMagick provides tools to perform a similar job from the command-line, making the chessboard a one-liner. $ N=8 $ PIXEL_WIDTH=200 $ convert -size $((N*15))x$((N*15)) pattern:checkerboard \ -monochrome -resize $PIXEL_WIDTH chessboard-magick.png Here, the checkerboard pattern is an ImageMagick built-in which, inspecting its output, happens to generate 15x15 squares (hence the 15’s in the script above). The -monochrome filter renders the pattern in black and white, rather than its native light- on dark-grey. The -size and -resize parameters should need no further explanation. The ((double parentheses)) perform Bash shell arithmetic. ImageMagick masquerades as a shell tool but really it’s a powerful and fully featured programmer’s imaging tool — a bit like a command-line version of Gimp2. Although well documented, my gut reaction is that it pushes the command-line interface too far. For more advanced image mangling, you’ll probably need a program to generate the one-liner needed to drive convert. Despite this reservation, it does the simple things simply, and it can do complex things too. Recommended! Google Chart API For a bit of fun, we can persuade Google to render the chessboard for us — in this case as a scatter plot using a square black markers[3]. We flip the PIL processing around, drawing black squares on the (default) white background, and using the usual plotting convention which places the origin at the bottom left. def chessboard_url(n=8, pixel_width=200): "Returns the URL of a chessboard graphic." def sq_midpt(i): "Return the x/y midpt of a square in column/row i." # For text encoding, the graphic's logical width is 100 return (0.5 + i) * 100. / n xys = [(sq_midpt(i), sq_midpt(j)) for i_start, j in zip(cycle((0, 1)), range(n)) for i in range(i_start, n, 2)] fields = dict(width=pixel_width, sqside=pixel_width/n, xs=",".join("%.02f" % x for x, _ in xys), ys=",".join("%.02f" % y for _, y in xys)) return ( "?" "cht=s&" # Draw a scatter graph "chd=t:%(xs)s|%(ys)s&" # using text encoding and "chm=s,000000,1,2.0,%(sqside)r&"# square black markers "chs=%(width)rx%(width)r" # at this size. ) % fields Note that we plot our chart on a logical 100 x 100 rectangle, the coordinate space mandated by the encoding we’ve chosen, then resize it to the physical dimensions supplied by the client. This function actually returns the URL of a PNG which the Google chart API serves up. Paste this URL into your browser address bar to see the graphic, or curl it to a local file.…&chs=200x200 $ url=`python chessboard_url.py` $ curl $url > chessboard.png We could embed the image into HTML using the IMG element, which is how I’ve embedded the image which you should see below. >>> from cgi import escape >>>>> img % escape(chessboard_url()) As you can see, we have plenty of options, but unfortunately the image itself isn’t suitable. You can’t get rid of the axes — or at least, I haven’t found a way to — and the rendered chart has some padding to the top and the right. And worse, we’re pretty much at the end of the line for this hack: if we wanted to do something more interesting, such as place pieces on the board, we’re out of luck. Of course this isn’t a flaw in the Google Chart API: we’ve actually asked it to draw a scatter plot of the centres of black squares on a chessboard, using square black markers, a job it’s done well enough. Some examples showing the proper use of Google charts can be found in an article I wrote about maximum sum subsequences. ASCII Text The chart URL might be considered a text encoding of the image; the actual graphic is returned by a server. There are other, more direct, textual representations. def outer_join(sep, ss): """Like string.join, but encloses the result with outer separators. Example: >>> outer_join('|', ['1', '2', '3']) '|1|2|3|' """ return "%s%s%s" % (sep, sep.join(ss), sep) def ascii_chessboard(n=8): """Draws an ASCII art chessboard. Returns a string representation of an n x n board. """ from itertools import islice, cycle divider = outer_join("+", "-" * n) + "\n" row0 = outer_join("|", islice(cycle(" B"), n)) + "\n" row1 = outer_join("|", islice(cycle("B "), n)) + "\n" return outer_join(divider, islice(cycle([row0, row1]), n)) I suspect this code was easier for me to write than it is for you to read! It treats the chessboard as a sequence of alternating rows of alternating squares, which are then joined together for output. >>> print ascii_chessboard(8) +-+-+-+-+-+-+-+-+ | |B| |B| |B| |B| +-+-+-+-+-+-+-+-+ |B| |B| |B| |B| | +-+-+-+-+-+-+-+-+ | |B| |B| |B| |B| +-+-+-+-+-+-+-+-+ |B| |B| |B| |B| | +-+-+-+-+-+-+-+-+ | |B| |B| |B| |B| +-+-+-+-+-+-+-+-+ |B| |B| |B| |B| | +-+-+-+-+-+-+-+-+ | |B| |B| |B| |B| +-+-+-+-+-+-+-+-+ |B| |B| |B| |B| | +-+-+-+-+-+-+-+-+ Not pretty, but such graphics may be useful in source code, which is typically viewed in a plain-text editor, and where ASCII art provides a way of embedding pictures right where they’re needed. On which point: if you’re working through “Structure and Interpretation of Computer Programs” you may like to know the book is available in Texinfo format, with the pictures all rendered in ASCII art. So you can split your editor window and run the code on one side, while browsing the book on the other. Here’s one of the figures: *Figure 4.6:* The `or' combination of two queries is produced by operating on the stream of frames in parallel and merging the results. +---------------------------+ | (or A B) | | +---+ | input | +->| A |------------+ | output stream of | | +---+ V | stream of frames | | ^ +-------+ | frames -------------* | | merge +---------------> | | | +-------+ | | | | ^ | | | | +---+ | | | +------->| B +------+ | | | +---+ | | | ^ | | | | | | +--*--+ | +---------|-----------------+ | data base Even though I own a copy of the book and the full text is available on-line, this primitive info version has become my preferred format when actually running the code examples and exercises. Unicode Block Elements Most programming languages may be stuck in ASCII, but we needn’t restict ourselves in this way. I found some block elements in the Geometrical Symbols section of the Unicode code charts (Unicode Block Elements (PDF)). Here’s a pre-rendered block of text composed of the light and dark shade block characters, U+2591 LIGHT SHADE and U+2593 DARK SHADE. And more I can think of plenty of other ways to draw a chessboard. My favourite drawing environments are the pencil and paper, and the pen and whiteboard; combine the former with a scanner and the latter with a digital camera and you’ve got an easy route to an electronic version of your design. For an HTML document I suspect SVG would be a good choice, but I don’t know enough about SVG to state this with confidence. I bet you could go a long way with CSS too. Wikipedia’s chess board is a table built on top of two small images, a light and a dark square, which I guess saves on bandwidth. Why? Why ever bother programming when all we want is a simple graphic? Well, for one thing, there’s not that much programming. The actual work of pushing pixels around is done by Google, or PIL, or ImageMagick. Once we’ve got a program written, it should be easy to adapt it. We’ve already put in hooks to specify the number of squares and the image dimensions. It’s equally easy to, for example, write out a JPEG rather than a PNG, or use different colours. A programmatic solution is dynamic. Google’s chart API generates pictures on the fly, based on data points, ranges etc. which clients choose as and when. It’s rather like lazy-evaluation: pre-rendering all possibilities isn’t just expensive, it’s out of the question. Teaser That’s quite enough pixels and characters for now, so this article will have to appear in two parts. If I’ve still not convinced you of the merits of creating images programmatically, please consider the following puzzle. How would you draw a position reached in a game of chess, showing both the board and the pieces? And if I have convinced you, this exercise makes for a good workout. Some Q&A’s. - Q: What position, exactly? - A: Any! - Q: How will the position be described? - A: Your choice — it’s an interesting part of the puzzle. A great starting point would be to solve the puzzle using an ASCII art representation. You can find my solution in this follow-up article. Thanks Thanks to Marius Gedminas and Johannes Hoff for their help bug-fixing this article. 1 I’m confused about where exactly PIL belongs; the official homepage seems to be on the PythonWare website (), but I usually head for the Effbot site,. I think the sites mirror the same information, so it boils down to whether you prefer a blue or green theme, and how off-putting you find all the ads-by-google. 2 Actually, you can use Gimp from the command-line, and it comes with some tools for creating and editing batch files, and indeed for creating a personal suite of image processing scripts. I’ve never used Gimp in this way, so I can’t say much more about this. [3] In theory you could use the Google Chart API to render any image in a pointillist manner: just plot enough pixels in the right places.
http://wordaligned.org/articles/drawing-chessboards
CC-MAIN-2021-49
refinedweb
2,022
70.33
AI is a superpower. And with power comes responsibility. This takes us into the domain of Responsible AI. In 2016, Microsoft released a bot named Tay on Twitter. However, over time, it started posting inflammatory speeches, causing a stir. We have heard of instances when AI agents discriminated against users based on race, gender, ethnicity, etc. Thus, in this age of AI empowerment, Responsible AI is of paramount importance. Responsible AI (RAI) is a huge topic. It is also an active area of research. While there are multiple tenets of Responsible AI, we can broadly categorize them into three viz. Fairness, privacy and interpretability. Together they make up the Responsible AI triad or the RAI triad. In this article, we will talk about the first amongst them. Further, we will throw light on some practical aspects of it with a concept called Differential Privacy. Also read: How to detect Data Drift in Azure Machine Learning Privacy Not all business domains can be democratic with their data. For instance, let’s take the healthcare domain, which is guided by laws like HIPAA. Any breach of privacy in healthcare data is extremely expensive and could lead to nefarious activity. However, Data Science projects involve a lot of Data Analysis. Thus, we have to provide Data Scientists with raw data, which may include sensitive data like salary or PHI (protected health information). Data analysts or scientists cannot work with dummy data for analysis. Fortunately, Data Analysis happens on aggregated or summarized data. Hence, distributions and summary statistics are sufficient for data analysts to make informed decisions. With predictive analytics, aggregates are of great help to decide on the next steps. Does this guarantee privacy though? Consider a case where multiple analyses of the data result in reported aggregations that, when combined, could reveal individuals in the source dataset. Suppose 10 participants share data about their location and salary, from which two reports emerge: - An aggregated salary report that tells us the average salaries in Mumbai, Bangalore, and Hyderabad - A worker location report tells us that 10% of the study participants (a single person) belong to Hyderabad. From these two reports, we can easily determine the specific salary of the Hyderabad participant. Anyone reviewing both studies who knows a person from Seattle who took part now knows that person’s salary. So what’s the way out? Can we keep the distribution roughly the same while adding some amount of noise to the data? Apparently, there is a way called Differential Privacy. Differential Privacy Differential Privacy is a technique for add statistical noise to the data. A parameter named epsilon governs the differential privacy algorithm. It is like the hyper-parameter of a machine learning algorithm and the difference between original and de-identified data is inversely proportional to the value of epsilon. Higher the value epsilon, your de-identified data is more similar to the original one. We won’t go into the mathematics of differential privacy, since it’s quite complex. Instead, we will look at its python package implementation. The python package is smart noise. For detailed code implementation, refer to this link: SmartNoise. Now, let’s walk through a piece of code. We will use the toy data, i.e. diabetes dataset. But first things first. Let us install the Smart Noise package. !pip install opendp-smartnoise Next, load diabetes data into a dataframe. import pandas as pd file_path = './diabetes.csv' df_diabetes = pd.read_csv(file_path) df_diabetes.describe() Next, let’s use the smart noise ‘Analysis’ and get the differentially private mean of the ‘Age’ column using the dp_mean method in the diabetes dataframe. import opendp.smartnoise.core as sn lst_cols = list(df_diabetes.columns) #get all columns age_range = [0.0, 120.0] #set the age range samples = len(df_diabetes) #numver of samples with sn.Analysis() as analysis: data = sn.Dataset(path=file_path, column_names=lst_cols) age_dt = sn.to_float(data['Age']) #Calculate differential privacy age_mean = sn.dp_mean(data = age_dt, privacy_usage = {'epsilon': .50}, data_lower = age_range[0], data_upper = age_range[1], data_rows = samples ) analysis.release() # print differentially private estimate of mean age print("Private mean age:", age_mean.value) # print actual mean age print("Actual mean age:", df_diabetes.Age.mean()) The result is: Private mean age: 30.168 Actual mean age: 30.1341 Now let’s change the epsilon value to 0.05: Private mean age: 30.048 Actual mean age: 30.1341 You can note two points here: - The differentially private mean differs from the actual mean age. - As epsilon decreases, the difference between original and actual data increases. Does this addition of noise affect the distribution of the data drastically? Let’s look at the code: Firstly, we plot the original distribution of the Age column. import matplotlib.pyplot as plt import numpy as np %matplotlib inline ages = list(range(0, 130, 10)) age = df_diabetes.Age # Plot a histogram with 10-year bins n_age, bins, patches = plt.hist(age, bins=ages, color='blue', alpha=0.7, rwidth=0.85) plt.grid(axis='y', alpha=0.75) plt.xlabel('Age') plt.ylabel('Frequency') plt.title('True Age Distribution') plt.show() print(n_age.astype(int)) Furthermore, let’s compare the original distribution with the differentially private distribution. import matplotlib.pyplot as plt with sn.Analysis() as analysis: data = sn.Dataset(path = file_path, column_names = lst_cols) age_histogram = sn.dp_histogram( sn.to_int(data['Age'], lower=0, upper=120), edges = ages, upper = 10000, null_value = -1, privacy_usage = {'epsilon': 0.5} ) analysis.release() plt.ylim([0,7000]) width=4 agecat_left = [x + width for x in ages] agecat_right = [x + 2*width for x in ages] plt.bar(list(range(0,120,10)), n_age, width=width, color='blue', alpha=0.7, label='True') plt.bar(agecat_left, age_histogram.value, width=width, color='orange', alpha=0.7, label='Private') plt.legend() plt.title('Histogram of Age') plt.xlabel('Age') plt.ylabel('Frequency') plt.show() print(age_histogram.value) This visual shows that the true distribution of the Age column is like differentially private distribution. Hence, we can keep the statistical value of the data while adding some noise to the original data. Conclusion Finally, let me be explicit that this is an active area of research. Hence, it will keep evolving and is an exciting space as AI applications get mainstream. Finally, this article is for information. Therefore, we do not claim any guarantees regarding the same.
https://www.data4v.com/a-look-at-differential-privacy/
CC-MAIN-2022-05
refinedweb
1,049
52.26