us Effect of new carbonyl cyanide aromatic hydrazones on biofilm inhibition against methicillin resistant Staphylococcus aureus By feeds.rsc.org Published On :: RSC Adv., 2020, 10,17854-17861DOI: 10.1039/D0RA03124K, Paper Open Access   This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.Xueer Lu, Ziwen Zhang, Yingying Xu, Jun Lu, Wenjian Tang, Jing Zhang2e and 2j with strong p-NO2 and p-CF3 at phenyl ring had the lowest MICs against S. aureus and MRSA. 2e displayed unaided or synergistic efficacy against MRSA, especially combined with ofloxacin. EM revealed that 2e destroys biofilms and cell membranes.The content of this RSS Feed (c) The Royal Society of Chemistry Full Article
us Nitrogen-doped RuS2 nanoparticles containing in situ reduced Ru as an efficient electrocatalyst for hydrogen evolution By feeds.rsc.org Published On :: RSC Adv., 2020, 10,17862-17868DOI: 10.1039/D0RA02530E, Paper Open Access   This article is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported Licence.Yan Xu, Xiaoping Gao, Jingyan Zhang, Daqiang GaoThe reasonable design that N-doping and in situ reduced Ru metal enhances the performance of N-RuS2/Ru for HER.The content of this RSS Feed (c) The Royal Society of Chemistry Full Article
us Nanoporous materials with predicted zeolite topologies By feeds.rsc.org Published On :: RSC Adv., 2020, 10,17760-17767DOI: 10.1039/D0RA01888K, Paper Open Access   This article is licensed under a Creative Commons Attribution 3.0 Unported Licence.Vladislav A. Blatov, Olga A. Blatova, Frits Daeyaert, Michael W. DeemTopological exploration of crystal structures demonstrates the presence of known zeolites, inorganics, and MOFs in a database of predicted materials.The content of this RSS Feed (c) The Royal Society of Chemistry Full Article
us Photograph of a curious cow By nicolasgallagher.com Published On :: Sun, 30 Aug 2009 17:00:00 -0700 Full Article
us Using HTML5 elements in WordPress post content By nicolasgallagher.com Published On :: Wed, 24 Feb 2010 16:00:00 -0800 Here are two ways to include HTML5 elements in your WordPress post content without WordPress’ wpautop function wrapping them in p tags or littering your code with line breaks. HTML5 has several new elements that you may want to use in your post content to markup document sections, headers, footers, pullquotes, figures, or groups of headings. One way to safely include these elements in your posts is simple; the other way is a bit more complicated. Both ways rely on hand-coding the HTML5 markup in the WordPress editor’s HTML view. If you are adding HTML5 elements to your post content then you should use an HTML5 doctype. Disable wpautop for your theme This is the simple way. Disable the wpautop function so that WordPress makes no attempt to correct your markup and leaves you to hand-code every line of your posts. If you want total control over every line of your HTML then this is the option for you. To disable wpautop entirely add these lines to your theme’s functions.php: remove_filter('the_excerpt', 'wpautop'); remove_filter('the_content', 'wpautop'); However, wpautop is generally quite useful if most of your posts are simple text content and you only occasionally want to include HTML5 elements. Therefore, modifying wpautop to recognise HTML5 elements might be more practical. Modify wpautop to recognise HTML5 elements WordPress’ wpautop is part of the core functions and can be found in this file within your WordPress installation: wp-includes/formatting.php. It controls how and where paragraphs and line breaks are inserted in excerpts and post content. In order to create a modified version of WordPress’ core wpautop function I started off by duplicating it in my theme’s functions.php file. What I’ve experimented with is disabling wpautop and adding a modified copy of it – which includes HTML5 elements in its arrayss – to my theme’s functions.php file. Add the following to your theme’s functions.php file and you’ll be able to use section, article, aside, header, footer, hgroup, figure, details, figcaption, and summary in your post content. (Probably best to try this in a testing environment first!) /* ----------------------------- MODIFIED WPAUTOP - Allow HTML5 block elements in wordpress posts ----------------------------- */ function html5autop($pee, $br = 1) { if ( trim($pee) === '' ) return ''; $pee = $pee . " "; // just to make things a little easier, pad the end $pee = preg_replace('|<br />s*<br />|', " ", $pee); // Space things out a little // *insertion* of section|article|aside|header|footer|hgroup|figure|details|figcaption|summary $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|header|footer|hgroup|figure|details|figcaption|summary)'; $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', " $1", $pee); $pee = preg_replace('!(</' . $allblocks . '>)!', "$1 ", $pee); $pee = str_replace(array(" ", " "), " ", $pee); // cross-platform newlines if ( strpos($pee, '<object') !== false ) { $pee = preg_replace('|s*<param([^>]*)>s*|', "<param$1>", $pee); // no pee inside object/embed $pee = preg_replace('|s*</embed>s*|', '</embed>', $pee); } $pee = preg_replace("/ +/", " ", $pee); // take care of duplicates // make paragraphs, including one at the end $pees = preg_split('/ s* /', $pee, -1, PREG_SPLIT_NO_EMPTY); $pee = ''; foreach ( $pees as $tinkle ) $pee .= '<p>' . trim($tinkle, " ") . "</p> "; $pee = preg_replace('|<p>s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace // *insertion* of section|article|aside $pee = preg_replace('!<p>([^<]+)</(div|address|form|section|article|aside)>!', "<p>$1</p></$2>", $pee); $pee = preg_replace('!<p>s*(</?' . $allblocks . '[^>]*>)s*</p>!', "$1", $pee); // don't pee all over a tag $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee); $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); $pee = preg_replace('!<p>s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)s*</p>!', "$1", $pee); if ($br) { $pee = preg_replace_callback('/<(script|style).*?</\1>/s', create_function('$matches', 'return str_replace(" ", "<WPPreserveNewline />", $matches[0]);'), $pee); $pee = preg_replace('|(?<!<br />)s* |', "<br /> ", $pee); // optionally make line breaks $pee = str_replace('<WPPreserveNewline />', " ", $pee); } $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)s*<br />!', "$1", $pee); // *insertion* of img|figcaption|summary $pee = preg_replace('!<br />(s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol|img|figcaption|summary)[^>]*>)!', '$1', $pee); if (strpos($pee, '<pre') !== false) $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee ); $pee = preg_replace( "| </p>$|", '</p>', $pee ); return $pee; } // remove the original wpautop function remove_filter('the_excerpt', 'wpautop'); remove_filter('the_content', 'wpautop'); // add our new html5autop function add_filter('the_excerpt', 'html5autop'); add_filter('the_content', 'html5autop'); The results are not absolutely perfect but then neither is the original wpautop function. Certain ways of formatting the code will result in unwanted trailing </p> tags or a missing opening <p> tags. For example, to insert a figure with caption into a post you should avoid adding the figcaption on a new line because an image or link appearing before the figcaption will end up with a trailing </p>. <!-- this turns out ok --> <figure> <a href="#"><img src="image.jpg" alt="" /></a><figcaption>A figure caption for your reading pleasure</figcaption> </figure> <!-- this turns out not so ok --> <figure> <a href="#"><img src="image.jpg" alt="" /></a> <figcaption>A figure caption for your reading pleasure</figcaption> </figure> Another example would be when beginning the contents of an aside with a paragraph. You’ll have to leave a blank line between the opening aside tag and the first paragraph. <aside> This content could be a pullquote or information that is tangentially related to the surrounding content. But to get it wrapped in a paragraph you have to leave those blank lines either side of it before the tags. </aside> Room for improvement Obviously there are still a few issues with this because if you format your post content in certain ways then you can end up with invalid HTML, even if it doesn’t actually affect the rendering of the page. But it seems to be pretty close! Leave a comment or email me if you are using this function and find there that are instances where it breaks down. I ran numerous tests and formatting variations to try and iron out as many problems as possible but it’s unlikely that I tried or spotted everything. Hopefully someone with more PHP and WordPress experience will be able to improve upon what I’ve been experimenting with, or find a simpler and more elegant solution that retains the useful wpautop functionality while allowing for the use of HTML5 elements in posts. Please share anything you find! Full Article
us Custom Tweet Button for WordPress By nicolasgallagher.com Published On :: Thu, 16 Sep 2010 17:00:00 -0700 How to create a custom Tweet Button for WordPress using the bit.ly and Twitter APIs. The HTML and CSS is completely customisable and there is no need for JavaScript. PHP is used to automatically shorten and cache the URL of a post, fetch and cache the number of retweets, and populate the query string parameters in the link to Twitter. The custom Tweet Button at the bottom of this post was created using this method. All the files are available on Github and released under MIT license. The PHP code was heavily influenced by the BackType Tweetcount plugin. How to use You’ll need your own bit.ly account and to be comfortable editing your theme’s functions.php, style.css, and template files. Be sure to make backups before you start making changes. Step 1: Download the Custom Tweet Button for WordPress files from Github. Step 2: Include the custom-tweet-button.php file in your theme’s functions.php file. Step 3: Replace the bit.ly username, bit.ly API key, and Twitter username placeholders in the tweet_button function with your own. Your bit.ly credentials can be found on the “settings” page of your account. Step 4: Add the custom Tweet Button CSS to your theme’s style.css file. Add the tweet.png image in your theme’s image folder. Make sure the image is correctly referenced in the CSS file. Step 5: Call the function tweet_button in your template files (e.g. single.php) at the position(s) in the HTML you’d like the Tweet Button to appear: if (function_exists('tweet_button')) { tweet_button(get_permalink()); } Why make your own Tweet Button? Making your own custom Tweet Button for WordPress has several additional advantages over using Twitter’s own offerings. Full control over the HTML and CSS. Having full control over the HTML and CSS means that you can choose how to present your Tweet Button. I decided to reproduce the horizontal and vertical styles of Twitter’s own button. But any appearance is possible. All click, traffic, and referrer data is stored in your bit.ly account. The URL for any published post is automatically shortened using the bit.ly service. The short URL is then passed to Twitter to ensure you can monitor the click and traffic data in your bit.ly account. The permalink is passed to Twitter in the counturl query string parameter to ensure that it counts the URL that your short URL resolves to. No need for JavaScript or embedded iframes. The Tweet Button works without JavaScript. You have full control over any custom JavaScript enhancements you may wish to include. If you’d prefer Twitter’s share page to open in a pop-up window you can write your own JavaScript handler. Faster page load. No external JavaScript or image files are loaded; both the short URL and retweet counts are cached. Use the short URL and retweet count for other purposes. The short URLs and retweet counts are stored as post meta-data. This makes it easy to display this data anywhere else in a post. The retweet count data could be used for conditional template logic. For example, you could order posts based on the number of retweets, apply custom styles to your most retweeted posts, or display your most tweeted posts in a widget. Easy to add Google Analytics campaign and event tracking. The Tweet Button is simple HTML and you have control over all the information that is sent to Twitter. Therefore, it is possible to use Google Analytics to help answer questions like: are people sharing your posts from the homepage or the post itself? If the Tweet Button is displayed above and below your posts, which gets the most clicks? How long do people take to click the Tweet Button? How many people are visiting my site thanks to links posted on Twitter using the Tweet Button? Approximate the number of retweets for old posts. Before the release of the official Tweet Button, Twitter did not collect data on the number of times a URL was tweeted. This means your older posts may display far fewer retweets than actually occurred. However, there is a workaround. Use a service like Topsy, Backtype, or Tweetmeme to get the number of times your old post was retweeted. The difference between this and the number from Twitter’s APIs is the approximate number of retweets Twitter missed. To correct the retweet count for old posts add the number of missed retweets to a Custom Field called retweet_count_start. How the custom Tweet Button works Once a post is published its permalink URL is shortened using the bit.ly API. The returned URL is permanently cached in the bitly_short_url Custom Field. The short URL is now part of the post’s general meta-data and can be used in contexts other than the Tweet Button. The Twitter API is used to get the number of retweets for the post’s permalink URL. This number, along with the time at which it was requested, is cached in the retweet_cache Custom Field. When the cache interval has passed, an API call is made and the returned number of retweets is checked against the value stored in retweet_cache. If the returned number is greater, the value of retweet_cache is updated. The content of the tweet is automatically created by setting several properties for the http://twitter.com/share URL. The post title makes up the message; the short URL is passed to Twitter as the URL to be displayed in the tweet; the permalink URL is passed to Twitter as the URL to be counted; and your username is declared. $twitter_params = '?text=' . urlencode($title) . '&url=' . urlencode($short_url) . '&counturl=' .urlencode($url). '&via=' . $twitter_via; The default HTML output is very simple and can be fully customised. To display the count number vertically, add the class vcount. <div class="twitter-share vcount> <a class="twitter-button" rel="external nofollow" title="Share this on Twitter" href="http://twitter.com/share?query-string-params" target="_blank">Tweet</a> <a class="twitter-count" href="http://twitter.com/search?q=url>259</a> </div> Further enhancements Please apply any improvements or enhancements for the script against the source repository. Full Article
us Better float containment in IE using CSS expressions By nicolasgallagher.com Published On :: Mon, 25 Apr 2011 17:00:00 -0700 Research into improving the cross-browser consistency of both the “clearfix” and “overflow:hidden” methods of containing floats. The aim is to work around several bugs in IE6 and IE7. This article introduces a new hack (with caveats) that can benefit the “clearfix” methods and the new block formatting context (NBFC) methods (e.g. using overflow:hidden) of containing floats. It’s one outcome of a collaboration between Nicolas Gallagher (that’s me) and Jonathan Neal. If you are not familiar with the history and underlying principles behind methods of containing floats, I recommend that you have a read of Easy clearing (2004), Everything you know about clearfix is wrong (2010), and Clearfix reloaded and overflow:hidden demystified (2010). Consistent float containment methods The code is show below and documented in this GitHub gist. Found an improvement or flaw? Please fork the gist or leave a comment. Micro clearfix hack: Firefox 3.5+, Safari 4+, Chrome, Opera 9+, IE 6+ .cf { /* for IE 6/7 */ *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif"); /* non-JS fallback */ *zoom: 1; } .cf:before, .cf:after { content: ""; display: table; } .cf:after { clear: both; } Overflow hack (NBFC): Firefox 2+, Safari 2+, Chrome, Opera 9+, IE 6+ .nbfc { overflow: hidden; /* for IE 6/7 */ *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif"); /* non-JS fallback */ *zoom: 1; } The GitHub gist also contains another variant of the clearfix method for modern browsers (based on Thierry Koblentz’s work). It provides greater visual consistency (avoiding edge-case bugs) for even older versions of Firefox. The only difference from existing float-containment methods is the inclusion of a CSS expression that inserts a clearing line-break in IE 6 and IE 7. Jonathan and I found that it helps to resolve some of the visual rendering differences that exist between these browsers and more modern ones. First I’ll explain what some of those differences are and when they occur. Containing floats in IE 6/7 In IE 6 and IE 7, the most common and robust method of containing floats within an element is to give it “layout” (find out more: On having Layout). Triggering “layout” on an element in IE 6/7 creates a new block formatting context (NBFC). However, certain IE bugs mean that previous float containment methods don’t result in cross-browser consistency. Specifically, this is what to expect in IE 6/7 when creating a NBFC: The top- and bottom-margins of non-floated child elements are contained within the ancestor element that has been given “layout”. (Also expected in other browsers when creating a NBFC) The bottom-margins of any right-floated descendants are contained within the ancestor. (Also expected in other browsers when creating a NBFC) The bottom-margins of any left-floated children are not contained within the ancestor. The margin has no effect on the height of the ancestor and is truncated, having no affect outside of the ancestor either. (IE 6/7 bug) In IE 6, if the right edge of the margin-box of a left-floated child is within 2px of the left edge of the content-box of its NBFC ancestor, the float’s bottom margin reappears and is contained within the parent. (IE 6 bug) Unwanted white-space can appear at the bottom of a float-container. (IE 6/7 bug) There is a lack of consistency between IE 6/7 and other browsers, and between IE 6 and IE 7. Thanks to Matthew Lein for his comment that directed me to this IE 6/7 behaviour. It was also recently mentioned by “Suzy” in a comment on Perishable Press. IE 6/7’s truncation of the bottom-margin of left-floats is not exposed in many of the test-cases used to demonstrate CSS float containment techniques. Using an IE-only CSS expression helps to correct this bug. The CSS expression Including the much maligned <br style="clear:both"> at the bottom of the float-container, as well as creating a NBFC, resolved all these inconsistencies in IE 6/7. Doing so prevents those browsers from collapsing (or truncating) top- and bottom-margins of descendant elements. Jonathan suggested inserting the clearing line-break in IE 6/7 only, using CSS expressions applied to fictional CSS properties. The CSS expression is the result of many iterations, tests, and suggestions. It runs only once, the first time an element receives the associated classname. *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif"); It is applied to zoom, which is already being used to help contain floats in IE 6/7, and the use of the runtimeStyle object ensures that the expression is replaced once it has been run. The addition of font:0/0 serif prevents the occasional appearance of white-space at the bottom of a float-container. And the * hack ensures that only IE 6 and IE 7 parse the rule. It’s worth noting that IE 6 and IE 7 parse almost any string used as CSS property. An earlier iteration used the entirely fictitious properties “-ms-inject” or “-ie-x” property to exploit this IE behaviour. *-ie-x: expression(this.x||(this.innerHTML+='<br style="clear:both;font:0/0">',this.x=1)); However, this expression is evaluated over and over again. Using runtimeStyle instead avoids this. Sergey Chikuyonok also pointed out that using innerHTML destroys existing HTML elements that may event handlers attached to them. By using document.createElement and appendChild you can insert the new element without removing all the events attached to other descendant elements. Containing floats in more modern browsers There are two popular methods to contain floats in modern browsers. Creating a new block formatting context (as is done in IE 6/7 when hasLayout is triggered) or using a variant of the “clearfix” hack. Creating a NBFC results in an element containing any floated children, and will prevent top- and bottom-margin collapse of non-floated children. When combined with the enhanced IE 6/7 containment method, it results in consistent cross-browser float containment. The other method, known as “clearfix”, traditionally used a single :after pseudo-element to clear floats in a similar fashion to a structural, clearing HTML line-break. However, to prevent the top-margins of non-floats from collapsing into the margins of their float-containing ancestor, you also need to use the :before pseudo-element. This is the approach taken in Thierry Koblentz’s “clearfix reloaded”. In contemporary browsers, the micro clearfix hack is also suitable. The method presented in this article should help improve the results of cross-browser float containment, whether you predominantly use “clearfix” or the NBFC method. The specific limitations of both the “clearfix” and various NBFC methods (as outlined in Thierry’s articles) remain. Problems Using a CSS expression to change the DOM in IE 6/7 creates problems of its own. Obviously, the DOM in IE 6/7 is now different to the DOM in other browsers. This affects any JavaScript DOM manipulation that may depend on :last-child or appending new children. This is still an experimental work-in-progress that is primarily research-driven rather than seeking to become a practical snippet of production code. Any feedback, further testing, and further experimentation from others would be much appreciated. Thanks to these people for contributing improvements: Jonathan Neal, Mathias Bynens, Sergey Chikuyonok, and Thierry Koblentz. Full Article
us Responsive images using CSS3 By nicolasgallagher.com Published On :: Wed, 18 May 2011 17:00:00 -0700 Future CSS implementations should allow for some form of responsive images via CSS alone. This is an early idea for how that might be done. However, a significant drawback is that it would not prevent both “mobile optimised” and larger size images from being requested at larger screen resolutions. Note that the CSS presented here is not supported in any browsers at the time of writing. This method relies on the use of @media queries, CSS3 generated content, and the CSS3 extension to the attr() function. The principles are basically the same as those underpinning Filament Group’s work on Responsive Images. The source image is “mobile optimised” and the urls of larger size images are included using HTML data-* attributes. <img src="image.jpg" data-src-600px="image-600px.jpg" data-src-800px="image-800px.jpg" alt=""> Using CSS @media queries you can target devices above certain widths. Within each media query block, images with larger alternatives can be targeted using an attribute selector. CSS3 generated content allows you to replace the content of any element using the content property. At the moment, only Opera 10+ supports it. In CSS 2.1, the content property is limited to use with the :before and :after pseudo-elements. By combining the content property with the CSS3 extension to attr(), you will be able to specify that an attribute’s value is interpreted as the URL part of a url() expression. In this case, it means you will be able to replace an image’s content with the image found at the destination URL stored in a custom HTML data-* attribute. @media (min-device-width:600px) { img[data-src-600px] { content: attr(data-src-600px, url); } } @media (min-device-width:800px) { img[data-src-800px] { content: attr(data-src-800px, url); } } Fork the Gist Issues Unfortunately, there are a number of issues with this technique. It doesn’t prevent multiple assets being downloaded at larger screen widths because network activity kicks in before CSS is applied. That means, for example, that desktop environments would make 2 HTTP requests for an image and have to load more assets than if they had been served only the larger image in the source. It makes the assumption that wider screens are tied to better internet connections. It forces authors to create and maintain multiple image sizes for each image. At present, using the context menu (or drag and drop) to copy the image will result in the source file being copied and not the replacement image. It doesn’t account for devices with different pixel densities. Full Article
us Custom CSS preprocessing By nicolasgallagher.com Published On :: Wed, 12 Mar 2014 17:00:00 -0700 Did you know that you can build your own CSS preprocessor with Node.js libraries? They can be used alongside established preprocessors like Sass, and are useful for defining tasks beyond preprocessing. Libraries like Rework and PostCSS let you create and assemble an arbitrary collection of plugins that can inspect or manipulate CSS. At the time of writing, Twitter uses Rework to perform various tasks against our CSS source code for twitter.com. Creating a CSS preprocessor with Rework At its core, Rework is a module that accepts a string of CSS, produces a CSS abstract syntax tree (AST), and provides an API for manipulating that AST. Plugins are functions that have access to the AST and a Rework instance. Rework lets you chain together different plugins and generate a string of new CSS when you’re done. The source string is passed into the rework function and each plugin is applied with .use(fn). The plugins transform the data in the AST, and .toString() generates the new string of CSS. Below is an example of a custom preprocessor script using Rework and Autoprefixer. It’s a simplified version of the transformation step we use for twitter.com’s CSS. var autoprefixer = require('autoprefixer'); var calc = require('rework-calc'); var rework = require('rework'); var vars = require('rework-vars')(); var css = fs.readFileSync('./css/main.css', 'utf-8'); css = rework(css) .use(vars) .use(calc) .toString(); css = autoprefixer().process(css); fs.writeFileSync('./build/bundle.css', css) The script runs rework-vars, rework-calc, and then passes the CSS to Autoprefixer (which uses PostCSS internally) to handle the addition of any necessary vendor prefixes. rework-vars provides a limited subset of the features described in the W3C-style CSS custom property spec. It’s not a polyfill! Variables can be declared as custom CSS properties on the :root element, prefixed with --. Variables are referenced with the var() function, taking the name of a variable as the first argument and an optional fallback as the second. For example, this source: :root { --width-button: 200px; } .button { width: var(--width-button); } yields: .button { width: 200px; } There are many different Rework plugins that you can use to create a custom preprocessor. A more complete list is available on npm. In order to limit the chances of long-term divergence between our source code and native CSS, I’ve chosen to stick fairly closely to features that are aligned with future additions to native CSS. Creating your own Rework plugin Rework plugins are functions that inspect or mutate the AST they are provided. Below is a plugin that rewrites the value of any font-family property to sans-serif. module.exports = function plugin(ast, reworkInstance) { ast.rules.forEach(function (rule) { if (rule.type != 'rule') return; rule.declarations.forEach(function (declaration, index) { if (declaration.property == 'font-family') { declaration.value = 'sans-serif'; } }); }); }; Rework uses css-parse to create the AST. Unfortunately, both projects are currently lacking comprehensive documentation of the AST, but it’s not difficult to piece it together yourself. Beyond preprocessing Since Rework and PostCSS expose an AST and provide a plugin API, they can be used for other CSS tasks, not just preprocessing. At Twitter, our CSS build pipeline allows you to perform custom tasks at 2 stages of the process: on individual files and on generated bundles. We use Rework at both stages. Individual files are tested with rework-suit-conformance to ensure that the SUIT-style CSS for a component is properly scoped. /** @define MyComponent */ :root { --property-MyComponent: value; } .MyComponent {} Bundles are preprocessed as previously described, and also tested with rework-ie-limits to ensure that the number of selectors doesn’t exceed IE 8/9’s limit of 4095 selectors per style sheet. Other tasks you can perform include generating RTL style sheets (e.g., css-flip) and extracting detailed information about the perceived health of your CSS (e.g., the number of different colours used, duplicate selectors, etc.). Hopefully this has given you a small glimpse into some of the benefits and flexibility of using these tools to work with CSS. Full Article
us How to test React components using Karma and webpack By nicolasgallagher.com Published On :: Sat, 16 May 2015 17:00:00 -0700 I’m working on a project at Twitter that uses React and webpack. After a few conversations with @sokra last year, this is the setup I put in place for testing React components (authored using JSX and ES6) using Karma. Dependencies You’ll need to install various packages. It looks like a lot of dependencies, but all the non-Karma packages will be necessary for general module bundling during development. Full set of required packages: babel-core: to transform JSX and transpile ES6. babel-loader: webpack loader for Babel. karma: the test runner. karma-chai-plugins: assertion library (or your library of choice). karma-chrome-launcher: Chrome browser launcher. karma-cli: CLI tool for Karma. karma-mocha: adapter for the Mocha testing framework. karma-sourcemap-loader: sourcemap loader. karma-webpack: to use webpack with Karma. react webpack: module bundler webpack entry file If you use webpack-specific features in your modules (e.g., loaders, plugins) you will need to use webpack to build a test bundle. The fastest and simplest approach is to create a single, test-specific entry file. Create a file named tests.bundle.js. Within this file, you create a webpack context to match all the files that conform to a naming pattern – in this case *.spec.js(x). var context = require.context('.', true, /.+.spec.jsx?$/); context.keys().forEach(context); module.exports = context; Next, you point Karma to this file. Karma config Karma is configured using a karma.conf.js file. The browsers, plugins, and frameworks are specified in the standard way. Point Karma at the tests.bundle.js file, and run it through the relevant preprocessor plugins (see example below). The karma-webpack plugin relies on 2 custom properties of the Karma config: webpack and webpackMiddleware. The value of the former must be a webpack config object. module.exports = function (config) { config.set({ browsers: [ 'Chrome' ], // karma only needs to know about the test bundle files: [ 'tests.bundle.js' ], frameworks: [ 'chai', 'mocha' ], plugins: [ 'karma-chrome-launcher', 'karma-chai', 'karma-mocha', 'karma-sourcemap-loader', 'karma-webpack', ], // run the bundle through the webpack and sourcemap plugins preprocessors: { 'tests.bundle.js': [ 'webpack', 'sourcemap' ] }, reporters: [ 'dots' ], singleRun: true, // webpack config object webpack: { devtool: 'inline-source-map', module: { loaders: [ { exclude: /node_modules/, loader: 'babel-loader, test: /.jsx?$/ } ], } }, webpackMiddleware: { noInfo: true, } }); }; Rather than duplicating your webpack config, you can require it in the Karma config file and override the devtool value to get sourcemaps working. var webpackConfig = require('./webpack.config'); webpackConfig.devtool = 'inline-source-map'; module.exports = function (config) { config.set({ ... webpack: webpackConfig }); }; That’s all you need to do to configure Karma to use webpack to load your JSX, ES6 React components. Full Article
us Using canvas to fix SVG scaling in Internet Explorer By nicolasgallagher.com Published On :: Mon, 18 May 2015 17:00:00 -0700 Internet Explorer 9–11 suffer from various bugs that prevent proper scaling of inline SVG’s. This is particularly problematic for SVG icons with variable widths. This is the canvas-based hack I’ve been using to work around the issue. A popular way to use SVG icons is to generate a spritemap of SVG symbol‘s that you then reference from elsewhere in a document. Most articles on the topic assume your icon dimensions are uniformly square. Twitter’s SVG icons (crafted by @sofo) are variable width, to produce consistent horizontal whitespace around the vectors. Most browsers will preserve the intrinsic aspect ratio of an SVG. Ideally, I want to set a common height for all the icons (e.g., 1em), and let the browser scale the width of each icon proportionally. This also makes it easy to resize icons in particular contexts – just change the height. Unfortunately, IE 9–11 do not preserve the intrinsic aspect ratio of an inline SVG. The svg element will default to a width of 300px (the default for replaced content elements). This means it’s not easy to work with variable-width SVG icons. No amount of CSS hacking fixed the problem, so I looked elsewhere – and ended up using canvas. canvas and aspect ratios A canvas element – with height and width attributes set – will preserve its aspect ratio when one dimension is scaled. The example below sets a 3:1 aspect ratio. <canvas height="1" width="3"></canvas> You can then scale the canvas by changing either dimension in CSS. canvas { display: block; height: 2rem; } Demo: proportional scaling of canvas. Fixing SVG scaling in IE This makes canvas useful for creating aspect ratios. Since IE doesn’t preserve the intrinsic aspect ratio of SVG icons, you can use canvas as a shim. A canvas of the correct aspect ratio provides a scalable frame. The svg can then be positioned to fill the space created by this frame. The HTML is straightforward: <div class="Icon" role="img" aria-label="Twitter"> <canvas class="Icon-canvas" height="1" width="3"></canvas> <svg class="Icon-svg"> <use fill="currentcolor" xlink:href="#icon-twitter"></use> </svg> </div> So is the CSS: .Icon { display: inline-block; height: 1em; /* default icon height */ position: relative; user-select: none; } .Icon-canvas { display: block; height: 100%; visibility: hidden; } .Icon-svg { height: 100%; left: 0; position: absolute; top: 0; width: 100%; } Setting the canvas height to 100% means it will scale based on the height of the component’s root element – just as SVG’s do in non-IE browsers. Changing the height of the Icon element scales the inner SVG icon while preserving its 3:1 aspect ratio. Demo: proportional scaling of svg in IE. Creating an Icon component The hack is best added to (and eventually removed from) an existing icon component’s implementation. If you’re generating and inlining an SVG spritemap, you will need to extract the height and width (usually from viewBox) of each of your icons during the build step. If you’re already using the gulp-svgstore plugin, it supports extracting metadata. Those dimensions need to be set on the canvas element to produce the correct aspect ratio for a given icon. Example React component (built with webpack): import iconData from './lib/icons-data.json'; import React from 'react'; import './index.css'; class Icon extends React.Component { render() { const props = this.props; const height = iconData[props.name.height]; const width = iconData[props.name.width]; // React doesn't support namespaced attributes, so we have to set the // 'use' tag with innerHTML const useTag = `<use fill="currentcolor" xlink:href="#icon-${props.name}"> </use>`; return ( <span className="Icon"> <canvas className="Icon-canvas" height={height} width={width} /> <svg className="Icon-svg" dangerouslySetInnerHTML={{__html: useTag}} key={props.name} /> </span> ); } } export default Icon; When I introduced this hack to a code base at Twitter, it had no impact on the the rest of the team or the rest of the code base – one of the many benefits of a component-based UI. Full Article
us Coronavirus | Lockdown chokes Maharashtra’s economic lifeline By www.thehindu.com Published On :: Sat, 09 May 2020 02:29:44 +0530 The industrial hub faces a massive shortfall in revenues amid growing cost of combating the pandemic Full Article Other States
us Coronavirus | Maharashtra adds 1,089 new cases; Mumbai’s death toll stands at 462 By www.thehindu.com Published On :: Fri, 08 May 2020 22:39:05 +0530 Of the 1,089 new cases, Mumbai accounted for 748, with a cumulative tally of 12,142. With 75 new cases, Pune district’s tally has risen to 2,537. Full Article Other States
us Coronavirus | Indore remains worst hit in Madhya Pradesh with 3 more deaths By www.thehindu.com Published On :: Sat, 09 May 2020 02:21:20 +0530 Bhopal, by comparison, has so far reported 679 cases and 24 deaths, with 354 patients, or more than half of those infected, having recovered. Full Article Other States
us Coronavirus | 390 new cases, 24 deaths in Gujarat; clashes in Ahmedabad By www.thehindu.com Published On :: Fri, 08 May 2020 23:22:50 +0530 Two prominent medical experts — AIIMS director Dr Randeep Guleriya and Dr. Manish Suneja — flew into Ahmedabad on Friday following instructions from the Home Minister to guide local doctors Full Article Other States
us Coronavirus | 87 fresh cases, 1 death in Punjab By www.thehindu.com Published On :: Fri, 08 May 2020 23:25:04 +0530 Major chunk of cases reported from Gurdaspur, Tarn Taran districts Full Article Other States
us Coronavirus | Odisha records 52 cases, highest single-day spike By www.thehindu.com Published On :: Fri, 08 May 2020 23:29:46 +0530 43 cases from Ganjam district; State’s total mounts to 271 Full Article Other States
us Coronavirus lockdown | With no work or food, workers brave the long march home from Uttar Pradesh By www.thehindu.com Published On :: Sat, 09 May 2020 10:06:56 +0530 "We don’t want anything from the government. We just want to be dropped home," says a migrant worker from Chhattisgarh. Full Article Other States
us PNB scam: HC rejects bail plea of accused who tested positive for COVID-19 By www.thehindu.com Published On :: Sat, 09 May 2020 01:43:26 +0530 Court says Hemant Bhatt needs to be treated at a govt. hospital Full Article Other States
us Teltumbde in judicial custody till May 22 By www.thehindu.com Published On :: Sat, 09 May 2020 01:47:19 +0530 A special National Investigation Agency (NIA) court on Friday extended the judicial custody of academician Dr. Anand Teltumbde, arrested on April 14 i Full Article Other States
us Coronavirus | 30 more test positive in J&K, cases mount to 823 By www.thehindu.com Published On :: Sat, 09 May 2020 02:01:16 +0530 Bandipora tops the list with 134 cases, followed by Srinagar at 129 Full Article Other States
us Crime Branch busts cigarette, tobacco smuggling racket By www.thehindu.com Published On :: Sat, 09 May 2020 02:16:50 +0530 Material brought illegally in vehicles that had permission to carry fruits and vegetables Full Article Other States
us Coronavirus | Nine deaths, 130 cases reported in Bengal By www.thehindu.com Published On :: Sat, 09 May 2020 02:05:54 +0530 This has been the highest spike in the number of cases in the State in a single day, taking the number of cases to 1,678 Full Article Other States
us Coronavirus | Assam rights activist held for social media post By www.thehindu.com Published On :: Sat, 09 May 2020 03:26:43 +0530 Rupa Rani Bhuyan, assistant professor of Mangaldoi College, was held for “misbehaving” with the police and “obstructing” them from investigating cases against her Full Article Other States
us Coronavirus | Tripura State Rifles men risk infection from BSF soldiers By www.thehindu.com Published On :: Sat, 09 May 2020 03:06:36 +0530 State health officials are planning extensive tests Full Article Other States
us Muslim villagers help Hindu woman's last rites By www.assamtimes.org Published On :: Thu, 26 Mar 2020 11:38:47 +0000 Full Article
us Illicit liquor racket busted By www.assamtimes.org Published On :: Tue, 31 Mar 2020 03:51:28 +0000 Full Article
us Participators in Nizamuddin event must undergo test By www.assamtimes.org Published On :: Wed, 01 Apr 2020 05:14:54 +0000 Full Article
us Strawberry cultivator’s hope blighted with frustration By www.assamtimes.org Published On :: Sat, 04 Apr 2020 11:37:04 +0000 Full Article
us Strategic excellence in the architecture, engineering, and construction industries [electronic resource] : how AEC firms can develop and execute strategy using lean Six Sigma / Gerhard Plenert and Joshua J. Plenert By prospero.murdoch.edu.au Published On :: Plenert, Gerhard Johannes, author Full Article
us Strategien zur Vermeidung von Burnout [electronic resource] : der mögliche Einfluss von Coping-Stilen / Markus H. Kipfer By prospero.murdoch.edu.au Published On :: Kipfer, Markus H, author Full Article
us Streamlining business requirements [electronic resource] : the XCellR8 approach / Gerrie Caudle By prospero.murdoch.edu.au Published On :: Caudle, Gerrie Full Article
us The stress test every business needs [electronic resource] : a capital agenda for confidently facing digital disruption, difficult investors, recessions and geopolitical threats / Jeffrey R. Greene, Steve Krouskos, Julie Hood, Harsha Basnayake, William Ca By prospero.murdoch.edu.au Published On :: Greene, Jeffrey R., author Full Article
us The subjective well-being module of the American Time Use Survey [electronic resource] : assessment for its continuation / Panel on Measuring Subjective Well-Being in a Policy-Relevant Framework, Committee on National Statistics, Division of Behavioral an By prospero.murdoch.edu.au Published On :: Full Article
us Succeeding in the project management jungle [electronic resource] : how to manage the people side of projects / Doug Russell By prospero.murdoch.edu.au Published On :: Russell, Doug Full Article
us Succeeding with SOA [electronic resource] : realizing business value through total architecture / Paul C. Brown By prospero.murdoch.edu.au Published On :: Brown, Paul C Full Article
us Successes and failures of knowledge management [electronic resource] / edited by Jay Liebowitz, Distinguished Chair of Applied Business and Finance, Harrisburg University of Science and Technology, Harrisburg, Pennsylvania By prospero.murdoch.edu.au Published On :: Full Article
us Superior customer value [electronic resource] : strategies for winning and retaining customers / Art Weinstein By prospero.murdoch.edu.au Published On :: Weinstein, Art, author Full Article
us Sustainability in supply chain management (collection) [electronic resource] / Peter A. Soyka, Robert Palevich, Steven M. Leon By prospero.murdoch.edu.au Published On :: Soyka, Peter A., 1958- author Full Article
us Sustainable engineering [electronic resource] : concepts, design, and case studies / David T. Allen, David R. Shonnard By prospero.murdoch.edu.au Published On :: Allen, David T Full Article
us Sustainable Global Value Chains [electronic resource] / edited by Michael Schmidt, Daniele Giovannucci, Dmitry Palekhov, Berthold Hansmann By prospero.murdoch.edu.au Published On :: Full Article
us Tail risk hedging [electronic resource] : creating robust portfolios for volatile markets / Vineer Bhansali By prospero.murdoch.edu.au Published On :: Bhansali, Vineer Full Article
us The talent equation [electronic resource] : big data lessons for navigating the skills gap and building a competitive workforce / Matt Ferguson, Lorin Hitt, Prasanna Tambe, with Ryan Hunt and Jennifer Sullivan Grasz By prospero.murdoch.edu.au Published On :: Ferguson, Matt Full Article
us Tapping into unstructured data [electronic resource] : integrating unstructured data and textual analytics into business intelligence / William H. Inmon, Anthony Nesavich By prospero.murdoch.edu.au Published On :: Inmon, William H Full Article
us Technology entrepreneurship [electronic resource] : taking innovation to the marketplace / Thomas N. Duening, Ph.D, El Pomar Chair of Business and Entrepreneurship, Director, Center for Entrepreneurship, College of Business, University of Colorado at Colo By prospero.murdoch.edu.au Published On :: Duening, Thomas N Full Article
us There's no such thing as an IT project [electronic resource] : a handbook for intentional business change / Bob Lewis, Dave Kaiser By prospero.murdoch.edu.au Published On :: Lewis, Bob, author Full Article
us Thinkers 50 business thought leaders from India [electronic resource] : the best ideas on innovation, management, strategy, and leadership / Stuart Crainer + Des Dearlove By prospero.murdoch.edu.au Published On :: Crainer, Stuart Full Article
us Thinkers 50 innovation [electronic resource] : breakthrough thinking to take your business to the next level / Stuart Crainer + Des Dearlove By prospero.murdoch.edu.au Published On :: Crainer, Stuart Full Article
us Tibco spotfire [electronic resource] : a comprehensive primer : create innovative enterprise-class informatics solutions using TIBCO Spotfire / Michael Phillips By prospero.murdoch.edu.au Published On :: Phillips, Michael, author Full Article
us Total quality management and just-in-time purchasing [electronic resource] : their effects on performance of firms operating in the U.S. / Hale Kaynak By prospero.murdoch.edu.au Published On :: Kaynak, Hale, 1956- Full Article