Mastering the Art of Bottle Conditioning

Bottling catches a lot of flack, especially from the die-hard keggers out there. Sure, preparing and filling a few cases of bottles is more labor-intensive than racking to a single keg, but packaging homebrew in bottles also has its benefits.

For one thing, grabbing a 6-pack of bottles to share or give to friends is quite a bit more convenient than shlepping a keg, CO2 tank and tap gear. Bottles are also perfect for long-term aging without taking up too much space in the cellar. And sometimes, there’s just nothing like popping a bottle of your own homebrew and hearing that “pffft” sound before pouring a beer into a glass.

To successfully bottle condition beer, it is important to take into account four key components: yeast, sugar, temperature and time.

Yeast

First and foremost, is yeast. Without enough viable yeast, there is nothing to convert sugar into CO2, which is what creates carbonation. If a beer undergoes a standard, healthy fermentation then there should be no issue with having enough yeast ready to do just a little bit more work to bottle condition beer.

Issues can arise, however. Extended fermentation periods, as well as highly flocculent yeast strains paired with lengthy secondary aging can cause yeast to go dormant. Filtering beer can also prevent enough viable yeast from making it into the bottling bucket. In these instances, more yeast can be pitched, which is actually sometimes standard procedure in many commercial breweries that bottle condition filtered beer.

The moral of the story—make sure the yeast is happy, healthy and up to the task of bottle conditioning your homebrew.

Sugar

The next vital key to the bottle conditioning puzzle is sugar. Without enough fermentable sugar, yeast will have nothing to transform into CO2 and carbonate beer. There are a few options for ensuring sugar levels are where they need to be to achieve the desired level of carbonation without fear of creating the dreaded “bottle bombs” (bottles that explode to due being over pressurized).

The daring homebrewer may determine when there’s just enough fermentable sugar left during fermentation and bottle at this point, but this is quite risky and without some experience with the particular recipe you’re brewing. The more common route is to wait for primary fermentation to complete fully, pick an easily fermentable sugar and add it to the bottling bucket. Rack the beer atop the sugar, mix it in thoroughly (without splashing!) and fill the bottles.

Corn sugar is the go-to priming sugar for many homebrewers because it is a simple sugar that is easily converted by yeast in a short time span. But brewers use everything from malt extract to honey to bottle condition beer. It is important to point out that different sugars have varying degrees of fermentability and will take different amount of times to achieve conditioning.

But wait! One of the most important parts of priming sugar is determining how much you need to achieve a specific level of carbonation, measured in volumes of CO2. The general rule of thumb used by beginners is 3/4 cup (177g) of corn sugar per 5 gallon batch to reach 2.25-2.5 vol. CO2. But, if you are after something with a higher or lower level of fizz, then you need to make some measurements.

Use the nomograph below to determine the amount of sugar you need to reach a specific level of carbonation. This is intended for a 5 gallon batch, but the amount of sugar determined for 5 gallons can be scaled to any volume. To use the nomograph, mark the temperature at which the beer will be bottled, the volumes of CO2 you’re after and then connect the lines with a straight-edge. Where the lines intersect the meter all the way to the right will determine how much corn or cane sugar is needed to reach that level of carbonation. Simple! Brewing software and online calculators can also be used to determine priming sugar amounts.

Carbonation Chart

Temperature

As with primary fermentation, temperature plays a big role in how efficiently yeast will do its job converting sugars into alcohol and CO2. At the very least, filled and capped bottles should be stored at the temperature it was held during primary fermentation. A little warmer can be even better. 68-80°F is the general range for bottle conditioning.

If you notice your bottles are having a hard time fermenting, but you’re confident with the yeast and priming sugar levels, it could very well be the temperature. Try sticking the bottles in a slightly warmer place and keep them off cold cellar floors that may be deceptively colder than the ambient temperature.

Time

Last but not least is time. Bottle conditioning typically takes 2-4 weeks to complete when using corn sugar. If you pop a bottle at two weeks, you’ll likely still hear the “pffft” of carbonation, assuming everything went to plan, but aging time up to a month is beneficial to ensure all the priming sugar has been consumed and the carbonation level has reached its fullest potential.

It’s important to remember that different priming sugars will take various lengths. Honey, for example, typically takes a bit longer than corn sugar. After two weeks, open a bottle every week or so and track the carbonation. Once you enjoy what you taste, it’s time to enjoy the fruits of your labor!

source: HBA

Posted in beer | Tagged , , | Leave a comment

Light Roast vs. Dark Roast Coffee: Which Packs More Health Perks?

light-roasted-coffee-beans

Both contain antioxidants and anti-inflammatory properties, but one brew takes the win, says a new study.

Coffee fanatics already know that their beverage of choice is rich in antioxidants, which may explain many of the health benefits associated with a regular morning joe or afternoon iced latte. But if you really want to maximize those good-for-you chemicals in every cup, a new study suggests opting for a light roast over dark.

For the new study, published in the Journal of Medicinal Food, Korean researchers compared coffees of several different roasting levels, analyzing their caffeine content and levels of chlorogenic acid, a well-known antioxidant. They also exposed extract of each coffee to human cell cultures to test their antioxidant and anti-inflammatory properties.

The results? The lighter the roast, the higher the chlorogenic acid content—and the better the coffee extract protected human cells against oxidation (cell damage) and inflammation when tested in the lab. Caffeine levels, on the other hand, did not vary significantly between samples.

These cell-culture findings could potentially translate to real-life benefits, says Sampath Parthasarathy, PhD, interim associate dean at the University of Central Florida School of Medicine and Journal of Medicinal Food editor-in-chief—but they need to be replicated in human trials before any definite conclusions can be formed.

“We know that antioxidants protect against many health problems, and we also know that inflammation is the basis of many chronic diseases, whether it is diabetes, heart disease, cancer, or neurological diseases like Alzheimer’s,” says Parthasarathy, who was not involved in the new study. “But these diseases are progressive and occur over a long period of time, and you can’t see long-term benefits in a test-tube study.”

The study specifically looked at Arabica coffee beans, roasted at levels corresponding to “light,” “medium,” “city,” and “French” roasts. The roasted beans were then ground and run through an espresso machine to obtain the extract used in testing.

Parthasarathy says it’s not surprising that lighter roasts would have higher levels of antioxidant activity. “When we roast something, we expose it to air,” he says. “There’s also a time element and a temperature element involved, and all of those things contribute to oxidation.”

This depletes the antioxidant molecules present in the coffee grinds, he continues. “They sacrifice themselves during the roasting process,” he says. “But ideally we would want to preserve them as much as possible, so they can have a better effect inside the body rather than getting wasted outside of it.”

While antioxidants aren’t always anti-inflammatory (and anti-inflammatory compounds aren’t always antioxidants), Parthasarathy says the two often go hand-in-hand.

If you love dark roasts for their flavor, Parthasarathy says you’re still likely getting some of the benefits. But cup for cup, lighter blends may have more powerful effects.

“If both types have the same amount of caffeine, why would you compromising on the antioxidant and anti-inflammatory effect?” he says. “People might have to ask themselves, to what extent is the aroma important to them? Are they drinking coffee for health, or just to feel good?”

Future studies may also help coffee producers make more health-focused decisions on the type of coffee and the level of roasting they choose to promote, he notes. Companies like Starbucks tout their dark French roast for its rich flavor, he says, “but it may not be better for health benefits.”

Of course, how long coffee is roasted for is only part of the equation when it comes to maximizing its superfood potential. Parthasarathy would also like to see more research on different types of beans grown in different regions and climates, and on different brewing processes, as well—like cold brew versus conventional.

“People drink coffee for flavor and for caffeine and for many other reasons, and many people won’t even want to start their day without it,” he says. “Most people don’t consider antioxidants or anti-inflammatory properties, but this study brings to light that the benefits of coffee—especially certain types of coffee—may be beyond what most people think.”

source: Health.com

Posted in Food and drink | Tagged , , | Leave a comment

How to Make a Heat Stick

Use and make at your own risk. Only use with a GFI outlet otherwise you could die!

The items you will need

You can use a different wattage hot water heater element depending on the amperage of the circuit you are using it on. If you don’t know anything about electrical, please don’t use anything higher than what i am suggesting here.

A 1500W will work on a 15A GFI circuit with no problem.

The items you will need are as follows:

  • 1500W 120v hot water heater element
  • 1 1/2″ chrome/brass sink waste arm
  • 1 1/2″ pvc elbow
  • 10 ft. Extension cord 15A rated or higher
  • JB weld
  • 1 #6 brass screw, nut, and washer
  • (not pictured):
  • 1 1/2″ pvc 8 inch straight section
  • 1 1/2″ pvc elbow
  • 1 1/2 ” pvc cap
  • 15 HD 3-prong plug.

punch a dimple in the waste arm to make it easier to get your drill started

First, you want to punch a dimple in the waste arm to make it easier to get your drill started. You then want to pick a drill bit the same size as your screw. Then drill a hole in the side of the waste arm.

hole drilled

After you’ve got your hole drilled you’re ready to get started with then next portion of the heat stick.

connect the white and black wires to either side of the posts of the element

Next, you want to connect the white and black wires to either side of the posts of the element, it doesn’t matter which side is which.

coat the entire end in jb-weld

Once your connections are tight, coat the entire end in jb-weld. Be very generous with the jb weld as you want to make sure no water can seep through.

Let the JB-weld cure for about an hour or so

Let the JB-weld cure for about an hour or so before you move on to the next step, so you don’t get JB-weld everywhere.

feed the screw, wrap the green wire around the screw, tighten the nut down. Make sure you coat everything on the inside very liberally with JB-weld.

Next you want to feed the screw through the hole in the side and on the inside the washer then the nut. Wrap the green wire around the screw and tighten the nut down. Make sure you coat everything on the inside very liberally with JB-weld. This has to be water tight. You can even put some around the screw on the outside.

Coat everything with all the jb-weld

Now feed the open end of the extension cord through the waste arm. And mount the heater element in place. Coat everything with all the jb-weld you can get on it, it has to be water tight.

screw the cap on the waste arm

Once everything is coated very well screw the cap on the waste arm. Make sure you fill any gaps you see with JB-weld as to make a water-tight seal. After this you can wait about 12 hours for the JB-weld to cure. After it’s fully cured stick it in a pot of hot water for about 10 minutes just to make sure it is water-proof.

the Heavy Duty 15 Amp plug

Here is the Heavy Duty 15 Amp plug, you don’t have to use this, but i would recommend it.

Secure the ends of the cable to the posts on the plug

Secure the ends of the cable to the posts on the plug. Like i said before the white and black don’t matter. The green does however, it should be hooked to the bottom prong on the plug, it will most likely be marked with green of some kind anyway.

Hook up the PVC

Hook up the PVC however you like, as you can see I wanted mine to be able to be hooked over the pot. Just make sure before you attach the plug you run your wire through the pvc section.

GFI outlet

This is a GFI outlet. Only use a Heat Stick if you have one of these otherwise you could die. Make sure to test it each time you use the Heat Stick to check functionality.

the first test

Now for the first test. Make sure the heat stick is submerged, and plug it in. It’s almost instantaneous heat. And because its only 1.5kw it’s very cheap to run. Absolutely do not plug in the heat stick unless it is submerged in water, the element will get red hot and fry.

Again, I am in no way responsible if you kill yourself using this. Use a Heat Stick at your own risk. They are very safe if made and used properly, if used improperly or not hooked up to a GFI circuit it could kill you.

source: loveBrewingCo

Posted in beer | Tagged , | Leave a comment

DIY: Kettle Etching

While it is possible to brew without the simplest of measurements, a key to repeatable recipes is measuring your ingredients. Your grain and hops may come pre-measured, but you still need to know how much water you’re using and how much wort is in your pot. I’ve gotten by for several years using a notched yardstick, and one of my kettles has a sight glass, but when I read an article about etching volume markers on a stainless steel kettle, I got excited—it sounded cheap and easy, I’d have one less piece of equipment to hassle with, and, it just looked cool.

In practice, it turned out to be more time consuming than I expected, and my results didn’t turn out as pretty as some of the examples I saw, but it was still a great learning experience, and I ended up with a functional solution.

Basic Idea

Electrolytic acid etching sounds fairly technical, but it’s just a matter of combining a DC power source, an acid medium to support the chemical process, and an applicator. In this case, the medium is a blend of vinegar and table salt, and the applicator is a cotton swab. The swab is attached to the negative lead of your power source and dipped into the vinegar solution. The positive lead is attached to the kettle, so touching the applicator to the metal completes a circuit and the electric current pulls metal ions from the steel. The resulting surface is roughened and reflects light differently from the smooth, unetched metal.

This process should work for both stainless steel and aluminum, but from what I’ve read, a significant number of people have had problems getting a lasting visible mark on aluminum. It’s a good idea to try it out on the bottom of your kettle first to make sure that it will work as expected.

For simplicity’s sake, the instructions below refer to gallons. However, if you use another unit of measure, you will want to tailor the units of measurement to your preference.

Equipment

  • DC power source (Some people have used a 9-volt battery, and others have tried similar sized DC adapters. I used a 12-volt car battery charger, which already had clips attached.)
  • ¼ cup (59 ml) white vinegar, with 1 Tbs salt dissolved in it
  • A supply of cotton swabs
  • Stencil materials (I used a combination of electrical tape and reusable vinyl stencils for the numbers.)
  • Levels
  • Large measuring cup or gallon jug
  • Latex gloves
  • Alcohol wipes
  • X-Acto knife
  • Bar Keepers Friend cleaner

Steps

There are three steps: stenciling out the volume marks and associated numbers, the etching process itself, and clean up.

Create the Stencil

You’ll need to locate where the volume marks belong and mark them out. One approach would be to use a grease pencil to make the marks, and then create the stencil once you’re done. I chose to use electrical tape that I could cut at the appropriate points. Here are the steps I followed:

Start with a clean, dry kettle. Clean the area you will be etching with alcohol wipes.

Apply two parallel strips of electrical tape about 1/4″ (6 mm) apart to the inside of the kettle—they will be placed vertically, as shown in the photo below.

kettle etch2

Place a few levels on the top of the kettle to make sure your water measurements will be precise (below).

kettle etch1

Add a measured gallon (or your unit of preference) of water and wait for the surface to settle.

Cut the right-sided strip of electrical tape at the level of the water.

Repeat the preceding two steps until you’ve made the full range of marks.

Empty and dry the kettle.

For each cut on the right-sided strip of electrical tape, make a second cut a little higher, and continue to work up the side of the pot.

Peel off the resulting thin bit of tape between the cuts. At this point, the stencil will reveal a design that looks something like one-half of a ladder.

Apply reusable number stencils immediately to the side of each ladder rung, as shown below.

kettle etch4

Etching Process

Before you continue, I think it’s important to keep in mind that you should take your time doing the etching. The longer you work each area of the stencil, the clearer the image will be.

Attach the negative lead to a cotton swab. If your lead is a loose wire, wrap it into the cotton puff, but leave the end of the swab clear. If you have an alligator clip, attach it to the cotton, below the top of the puff. You can see how I rigged mine in the photo below.

kettle etch3

Attach the positive lead to the kettle, relatively close the specific area that’s being etched (you can see how I worked in the photo below). A loose wire can be taped in place. If you have a clip, it can be attached to the edge of the pot. You can also just hold it in contact with the metal if you prefer.

kettle etch5

Dip the applicator into the vinegar solution.

Put the applicator in contact with the metal inside the bounds of the stencil. You should see some bubbling, and the liquid around the swab will turn yellow/brown.

kettle etch6

Touch the applicator to each section of the stencil, making sure it is in contact with the kettle for at least 30−60 seconds in each spot. Redip the swab often to keep it damp.

Replace the cotton swabs when they become worn down and badly discolored and reattach the negative lead each time.

Wipe away excess liquid as necessary.

Cleanup

Once the etching is done, remove the stencil completely, clean the inside of the kettle using Bar Keepers Friend, and rinse the inside of the kettle.

Takeaways

In the process of doing this, I learned a couple of things. The first is that reusable number stencils can be tricky. Interior elements of the stencil sometimes slipped, making the number less distinct. Also, I needed to be more patient during the etching process. I ended up with some areas that were lighter than I wanted. Still, my first attempt was successful, and I’m looking forward to my next brewing session to try out my kettle.

kettle etch7

source: beerandbrewing

also: “Etch Your Kettle – mark metal”

Posted in beer, Info | Tagged , , , | Leave a comment

ELAN Smart-Pad Edge Scroll in Windows 10

It seems to be missing settings and have no option for one-finger scroll after driver update for ELAN Smart-Pad version 11.15.0.14.

I found a working solution, and it even uses an updated driver!

  1. Open Internet Explorer (Sorry, doesn’t work on Edge or any other browser)
  2. Go to Microsoft’s update catalog
  3. If the screen you get is solid blue or missing the search bar, you might be missing a plugin. Refresh the page and there should be an option to install it.
  4. The page should now look like this. Search “Elan Input Device”.
  5. Press the “Last Update” column header. It should now be sorted by the most recent release.
  6. Click the titles on both of these (you may need to enable popups). Check inside the popup if the architecture is for AMD64 (64-bit) or x86 (32-bit). The reason I ignored the top two results is because they are exclusively for Toshiba pcs.
  7. Click “Add” ONLY if the driver is both compatible with your OS version (Windows 10) AND the correct architecture for your system (AMD64 = 64-bit Windows ; x86 = 32-bit Windows). If not, close the popup and keep selecting titles until you find a match.
  8. Near the top right of your screen, you should see “view basket (1)”. If you have a number, sucess, your driver has been added. Click on it.
  9. Press “Download” and curse Microsoft for their convoluted driver update system.
  10. Choose where you want the driver to download (I just chose the default Downloads folder).
  11. Locate the downloaded driver file (.cab). Extract it to another folder by using WinRAR, 7zip, or open a command prompt and use expand[2] .

WHAT? WAIT. HOW DO I INSTALL IT?

Manually.

  1. Open “Device Manager” (Right Click on Start Menu).
  2. Locate “Mice and other pointing devices” and expand it.
  3. Right click on “ELAN Input Device” and select “Update Driver”.
  4. Choose “Browse my computer for driver software.”
  5. Choose “Browse” and select the folder where you extracted the driver files.
  6. Choose next and cross your fingers. Restart your pc after installation for the changes to apply.
  7. Head back to device manager, right click “ELAN Input Device,” and select “properties.” It should now be version “15.6.2.1.”
  8. Navigate to: Settings > Devices > Mouse & Touchpad > Additional Mouse Options. See if there is an ELAN tab.
  9. Enable it if necessary. Then choose options.
  10. This window should appear. Choose “Edge Scroll”, enable Vertical and Horizontal scroll, and apply your changes.
  11. You should be all set, this solution worked for me and I hope it works for you too! (P.S.: I basically expanded upon this post and changed the instructions from the sound driver to the Elan driver, as well as going into more detail on some instructions.)

Source: ELAN Smart-Pad settings gone after Windows 10 update – Microsoft Community

Posted in Computer | Tagged , , , , , | Leave a comment

Deep dive CSS: font metrics, line-height and vertical-align – Vincent De Oliveira

An introduction to the inline formatting context. Explores line-height and vertical-align properties, as well as the font metrics. Understand how text is rendered on screen, and how to control it with CSS.

Source: Deep dive CSS: font metrics, line-height and vertical-align – Vincent De Oliveira

Posted in Dev | Tagged , | Leave a comment

15 useful utilities for windows 10

  1. Synergy (Share a mouse and keyboard across computers)
    Share a mouse and keyboard across computers
    If you have more than one machine on your desk, you know it’s a pain to have multiple keyboards and mice. Synergy is a virtual KVM that works across PCs, Macs, and Linux boxes. It’s $19, but worth it.
  2. Spacedesk (Turn your tablet into an external monitor)
    Turn your tablet into an external monitor
    It’s well known that more screen real estate increases productivity. Given we all have tablets lying around, why not use them as an extra screen for your laptop? That’s what Spacedesk is does for you, for free.
  3. Reaconverter (Automatically modify images in bulk)
    Automatically modify images in bulk
    If have any kind of bulk image converting tasks, Reaconverter is the tool to use. You can create simple scripts and droplets that will transform entire folders nearly instantly. There’s a free version.
  4. KeyTweak (Customize keyboard behavior at the nano-level)
    Customize keyboard behavior at the nano-level
    KeyTweak looks old because it’s been around for a long time. But it still works and it’s free. If you need to surgically alter your keyboard, this is the tool for you. Not for newbies.
  5. PC Decrapifier (Eliminate excess software)
    Eliminate excess software
    It’s hard to believe, but PCs still come loaded with crap. PC Decrapifier has been with us for years and is still a go-to tool to clean the crap from your machine. It’s a free download.
  6. MysticThumbs (Display image thumbnails instead of generic icons)
    Display image thumbnails instead of generic icons
    The Windows desktop and File Explorer show thumbnails for some file formats, but not all. If you want to see (and customize) thumbnails for many more formats, MysticThumbs is your friend. $30. Just one snag: it has a problem displaying thumbnails from shares.
  7. Revo Uninstaller Pro (Uninstall stubborn apps)
    Uninstall stubborn apps
    At almost $40, this isn’t cheap. But if you want to cleanly remove applications from your Windows install, Revo Uninstaller Pro can save you a lot of time, and even save you from having to do a fresh install… for a while.
  8. Mobile Net Switch is a tool (Switch to the right network)
    Switch to the right network
    For those who remember NetProfileSwitch, Mobile Net Switch is a tool that’s been updated for Windows 10. As you move from network to network, it adjusts your PC’s network configuration automatically. About $30.
  9. Speccy (Find out what’s in your computer)
    Find out what's in your computer
    If you’ve ever needed to know your machine’s configuration (say, to find the right drivers), Speccy is the go-to product. There’s a free version that should do for most needs.
  10. Recover Keys (Find keys for installed products)
    Find keys for installed products
    If you want to reinstall your system, it’s often necessary to re-register with the appropriate product key. If you can’t find your original order, the $30 Recover Keys can help.
  11. WinDirStat (Find what’s clogging your storage)
    Find what's clogging your storage
    Why is my drive suddenly full? Ever have that happen to you? With WinDirStat, you can see all your files at a glance and easily see the clusters of files that are taking up way too much space. Oh, yeah. It’s totally free.
  12. Quick Assist (Avoid driving 3 hours to fix Mom’s computer)
    Avoid driving 3 hours to fix Mom's computer
    Back in the day, there was Windows Remote Assistant. Today, Windows 10 supports Quick Assist, which will help you fix machines remotely. If both of you don’t run Windows 10, consider TeamViewer — there’s a free version.
  13. 7-zip (Uncompress pretty much everything)
    Uncompress pretty much everything
    So someone just sent you a file compressed with some odd format. Consider 7-Zip your go-to tool. It can uncompress 7z, XZ, BZIP2, GZIP, TAR, ZIP, WIM, AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and Z files.
  14. VLC (Play nearly every media format)
    Play nearly every media format
    Affectionately known as “the cone,” VLC will play nearly any media format you can think of (and many you can’t). Plus, it’s free. You can’t beat that!
Posted in Computer | Leave a comment

Beer — how it is made by corporations

Secrets Of Beer Exposed

Алекс Джонс: Из чего делают пиво?

foodbabe.com/beer

Posted in beer | Tagged , | Leave a comment

Transparent JPG (With SVG)

Let’s say you have a photographic image that really should be a JPG or WebP, for the best file size and quality. But what if I need transparency too? Don’t I need PNG for that? Won’t that make for either huge file sizes (PNG-24) or weird quality (PNG-8)? Let’s look at another way that ends up best-of-both-worlds.

The original photographic image.

The goal is to clip myself out of the image, removing the background. My technique for that is usually to use Photoshop and cut a clipping path manually with the Pen tool.

Now I can select the inverse of that clipping path to easily remove the background.

Attempting to save this as a 1200px wide image as PNG-24 out of Photoshop ends up as about a 1MB image!

1MB is huge 🙁

We could cut that by 75% using PNG-8, but then we 1) get that weird Giffy look (less photographic) and 2) have to pick a matte color for the edges because we aren’t getting nice alpha transparency here, just binary transparency.

Much better file size, but quality is weird.

Gosh what if we could just use JPG? The quality and file size is way better.

No transparency though.

But wait! Can’t we just clip this thing out? We have clip-path now. Well… yeah. We do have clip-path. It can’t take a path(), though, and what we’ve created for vector points in Photoshop is path data. It could take a polygon() though, if we made all the lines straight. That’s probably not ideal (I’m curvy!). Or we could make a <clipPath> element in some inline SVG and use clip-path: url(#id_of_clipPath);, which does support a <path> inside.

There is masking as well, which is another possibility.

Let’s look at a third possibility though: put everything into <svg>. That made some logical sense to me, so all this stays together and scales together.

The trick is to make two things:

  1. The JPG
  2. The clipping <path>

The JPG is easy enough. Output that right from Photoshop. Optimize.

Now we can set up the SVG. SVG is happy to take a raster graphic. SVG is known for vector graphics, but it’s a very flexible image format.

<svg>
  <image xlink:href="/images/chris.jpg" x="0" y="0">
<svg>

To get the path, we export the path we created with the Pen tool over to Illustrator.

Now we have the path over there, and it’s easy to export as SVG:

Now we have the path data we need:

Even with all those points, this was 1.5K unoptimzed and ungzipped. Not much overhead.

Let’s use that <path> within a <clipPath> in the SVG we’ve started. Then also apply that clip path to the <image>:

<svg viewBox="0 0 921.17 1409.71">
  <defs>
    <clipPath id="chris-clip">
      <path d=" ... " />
    </clipPath>
  </defs>
  <image xlink:href="/images/chris.jpg" clip-path="url(#chris-clip)" x="0" y="0">
<svg>

Tada!

A transparent JPG, essentially.

source: css-tricks

Posted in Dev, Technology | Tagged , , , , | Leave a comment

20 Awesome PHP Libraries For Early 2017

This week we have for you a collection of high-quality PHP libraries that have caught our eye in the last couple of months. We’ve tried our best to include projects that are active, well documented, and will have a realistic shot at finding a place in your developer’s workbelt.

If we’ve haven’t included your favorite new library, feel free to share it in the comments 🙂


Requests for PHP

A no-dependencies library that lets you send HTTP requests. It provides the needed methods for adding headers, accessing response data, handling forms, and everything else you may need, neatly packaged in a clean and easy to use API.

$headers = array('Accept' => 'application/json');
$options = array('auth' => array('user', 'pass'));
$request = Requests::get('https://api.github.com/gists', $headers, $options);

var_dump($request->status_code);
// int(200)

var_dump($request->headers['content-type']);
// string(31) "application/json; charset=utf-8"

var_dump($request->body);
// string(26891) "[...]"

Rinvex Country

Rinvex Country is a PHP package that lets developers retrieve detailed information about the countries of the world. Using the over 50 methods you can get the area of Angola, the currency of Cyprus, the native name of Namibia or even the FIFA name of Finland. There is a ton of info available and the data sources are pretty reliable.

$egypt = country('eg');

$egypt->getCapital();   // Cairo
$egypt->getDemonym();   // Egyptian
$egypt->getTld();       // .eg
$egypt->getContinent(); // Africa
$egypt->getSubregion(); // Northern Africa
$egypt->getBorders();   // ["ISR","LBY","SDN"]

Botman

A PHP library for developing messenger bots. Works with most of the popular messaging platforms including Facebook Messenger, Slack, Telegram, WeChat, and others. There is also a helpful boilerplate Laravel project available here.

// create an instance
$botman = BotManFactory::create($config);

// give the bot something to listen for.
$botman->hears('hello', function (BotMan $bot) {
    $bot->reply('Hello yourself.');
});

// start listening
$botman->listen();

If you are not familiar with the concept of messenger bots we suggest you check out our article Developer’s Introduction To Chatbots.


Charts

Laravel package for generating highly customizable charts out of datasets. The package works as a PHP wrapper for multiple built-in JavaScript chart libraries, allowing devs to create a wide variety of graphs, gauges and progressbars using only one tool.

$chart = Charts::create('line', 'highcharts')
    ->view('custom.line.chart.view') 
    ->title('My nice chart')
    ->labels(['First', 'Second', 'Third'])
    ->values([5,10,20])
    ->dimensions(1000,500)
    ->responsive(false);

Swap

Swap allows you to retrieve currency exchange rates from a number of services such as Fixer, Google, and Yahoo. Request responses can be easily cached and accessed later. The library is available in the form of a Laravel Package as well.

// Build Swap with Fixer.io
$swap = (new Builder())
    ->add('fixer')
    ->build();
    
// Get the latest EUR/USD rate
$rate = $swap->latest('EUR/USD');

// 1.129
$rate->getValue();

// Get the EUR/USD rate 15 days ago
$rate = $swap->historical('EUR/USD', (new \DateTime())->modify('-15 days'));

Math PHP

A collection of mathematical functions and algorithms ranging from simple algebra to finances, statistics, numerical analysis and others fields. The library is modular, has a straightforward API, and doesn’t require any external dependencies.

// Factors of an integer
$factors = Algebra::factors($n);

// Fibonacci sequence
$fib = Advanced::fibonacci($n);

// Combinations
$nCk  = Combinatorics::combinations($n, $k);

// Likelihood ratios
$LL = Experiment::likelihoodRatio($a, $b, $c, $d);

PHPUnit

PHPUnit is an advanced testing framework that enables teams to thoroughly test their code. Unit tests are written in standalone object-oriented classes with the help of many methods for handling assertions, dependencies, etc. A simple CLI is provided for running test and generating reports.

class StackTest extends TestCase
{
    public function testPushAndPop()
    {
        $stack = [];
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}

Atoum

A less popular testing framework we also wanted to share. Atoum offers a one-step installation precess and a relatively simple workflow, while still maintaining a ton of great features. It has a mock engine, expressive assertions, and a CLI that can execute multiple tests in parallel.

$this->given($testedInstance = new testedClass())
    ->and($testedClass[] = $firstValue = uniqid())
    ->then
        ->sizeof($testedInstance)->isEqualTo(1)
        ->string($testedClass[0])->isEqualTo($firstValue);

Simple Regex Language

A PHP implementation of the Simple Regex Language – a verbose way of writing regular expressions. The library provides multiple methods that can be chained together, forming readable and easy to understand RegEx rules. The library has ports for JavaScript and Python as well.

$query = SRL::startsWith()
    ->anyOf(function (Builder $query) {
        $query->digit()
            ->letter()
            ->oneOf('._%+-');
    })->onceOrMore()
    ->literally('@')
    ->anyOf(function (Builder $query) {
        $query->digit()
            ->letter()
            ->oneOf('.-');
    })->onceOrMore()
    ->literally('.')
    ->letter()->atLeast(2)
    ->mustEnd()->caseInsensitive();

Stash

Stash makes it easy to speed up your code by caching the results of expensive functions or code. Certain actions, like database queries or calls to external APIs, take a lot of time to run but tend to have the same results over short periods of time. This makes it much more efficient to store the results and call them back up later.

$pool = $this->cachePool;

// Get a Stash object from the cache pool.
$item = $pool->getItem("/user/{$userId}/info");

// Get the data from it, if any happens to be there.
$userInfo = $item->get();

// Check to see if the cache missed, which could mean that it either
// didn't exist or was stale.
if($item->isMiss())
{
    // Run the relatively expensive code.
    $userInfo = loadUserInfoFromDatabase($userId);

    // Set the new value in $item.
    $item->set($userInfo);

    // Store the expensive code so the next time it doesn't miss.
    $pool->save($item)
}

PHP VCR

A port of the popular Ruby library for testing HTTP interactions. PHP VCR records HTTP requests and stores them in “cassettes” which can be replayed later on. A set of testing utilities are also provided, making it possible to inspect and compare recordings in detail.

// After turning on, the VCR will intercept all requests
\VCR\VCR::turnOn();

// Record requests and responses in cassette file 'example'
\VCR\VCR::insertCassette('example');

// Following request will be recorded once and replayed in future test runs
$result = file_get_contents('http://example.com');
$this->assertNotEmpty($result);

// To stop recording requests, eject the cassette
\VCR\VCR::eject();

// Turn off VCR to stop intercepting requests
\VCR\VCR::turnOff();

OAuth 2.0 Server

This library allows you to easily configure an OAuth 2.0 server and set up all the authentication levels needed to protect your API. It is fully standards compliant and supports all the grants defined by OAuth protocol. The Laravel Passport module is built on top of the OAuth 2.0 Server.

// Setup the authorization server
$server = new \League\OAuth2\Server\AuthorizationServer(
    $clientRepository,
    $accessTokenRepository,
    $scopeRepository,
    $privateKey,
    $publicKey
);

// Enable a grant on the server
$server->enableGrantType(
    new \League\OAuth2\Server\Grant\ClientCredentialsGrant(),
    new \DateInterval('PT1H') // access tokens will expire after 1 hour
);

Imagine

An image manipulation library that tries to bring together all low level PHP image processing libraries under the same object-oriented API. This allows Imagine to be used for a wide variety of tasks such as drawing, resizing, cropping, filters, effects, metadata editing, and others.

$palette = new Imagine\Image\Palette\RGB();

$image = $imagine->create(new Box(400, 300), $palette->color('#000'));

$image->draw()
    ->ellipse(new Point(200, 150), new Box(300, 225), $image->palette()->color('fff'));

$image->save('/path/to/ellipse.png');

MINI

Extremely simple and easy to understand skeleton PHP application, providing only the most essential features every project needs. It does not strive to be a do-it-all framework like Laravel, but due to it’s simplicity MINI can be used for getting smaller apps up and running in no time.

// Working with the model
$songs = $this->model->getAllSongs();
$amount_of_songs = $this->model->getAmountOfSongs();

// Loading views
require APP . 'views/_templates/header.php';
require APP . 'views/songs/index.php';
require APP . 'views/_templates/footer.php';

AWS SDK

The official PHP library for working with Amazon Web Services. The SDK makes it easy to connect AWS with any PHP project and access all the various available services. There is also a useful Laravel wrapper which can be found here.

// Instantiate an Amazon S3 client.
$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);

$s3->putObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'my-object',
    'Body'   => fopen('/path/to/file', 'r'),
    'ACL'    => 'public-read',
]);

Purl

Lightweight PHP library for working with URLs. With Purl you can compose complex paths attribute by attribute, extract data from URLs, manipulate queries, recognize URLs in strings, and much more.

$url = \Purl\Url::parse('http://jwage.com')
    ->set('scheme', 'https')
    ->set('port', '443')
    ->set('user', 'jwage')
    ->set('pass', 'password')
    ->set('path', 'about/me')
    ->set('query', 'param1=value1&param2=value2');

echo $url->getUrl(); // https://jwage:[email protected]:443/about/me?param1=value1&param2=value2
echo $url->publicSuffix; // com
echo $url->registerableDomain; // jwage.com

Daux.io

Documentation generator that uses a simple folder structure and Markdown files to create responsive documentation websites. Daux.io has automatic syntax highlighting, 4 theming options, Bootstrap HTML for easy customization, navigation with readable URLs, and many other goodies.

// Example configuration
{
    "title": "DAUX.IO",
    "tagline": "The Easiest Way To Document Your Project",
    "author": "Justin Walsh",
    "image": "app.png",
    "html": {
        "theme": "daux-blue",
        "breadcrumbs": true,
        "repo": "justinwalsh/daux.io",
        "edit_on_github": "justinwalsh/daux.io/blob/master/docs",
        "twitter": ["justin_walsh", "todaymade"],
        "google_analytics": "UA-12653604-10",
        "links": {
            "Download": "https://github.com/justinwalsh/daux.io/archive/master.zip",
            "GitHub Repo": "https://github.com/justinwalsh/daux.io",
            "Made by Todaymade": "http://todaymade.com"
        }
    }
}

Dompdf

Dompdf is a PDF generator that takes regular HTML markup and converts it to .pdf files. It understands most CSS rules, which can be fed in-line or via an external stylesheet.

// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream();

Instaphp

Non-official library for accessing the Instagram API. It provides developers with an easy way to authenticate their app and get access to various Instagram data endpoints including images, users, likes, comments, and tags.

$api = new Instaphp\Instaphp([
    'client_id' => 'your client id',
    'client_secret' => 'your client secret',
    'redirect_uri' => 'http://somehost.foo/callback.php',
    'scope' => 'comments+likes'
]);

$popular = $api->Media->Popular(['count' => 10]);

if (empty($popular->error)) {
    foreach ($popular->data as $item) {
        printf('<img src="%s">', $item['images']['low_resolution']['url']);
    }
}

Latitude

Zero-dependencies library for building SQL queries using chainable methods. It supports most query types and works well with MySQL, Postgres, SQL Server, and other databases. There are also built-in escaping helpers for protecting against SQL injection.

$select = SelectQuery::make(
        'id',
        'username'
    )
    ->from('users');

echo $select->sql();
// SELECT id, username FROM users

source: tutorialzine

Posted in Dev, Technology | Leave a comment