Snipplrhttp://snipplr.com/tags/transform
Recent snippets posted on Snipplr.comen-usMon, 03 Aug 2015 08:29:25 GMT(Java) Convert Each TIFF Frame to JPEG &amp; Transform them to PDF Format Using Java - johansonkatherinehttp://snipplr.com/view/73485/convert-each-tiff-frame-to-jpeg--transform-them-to-pdf-format-using-java/
This technical tip shows how each TIFF frame can be converted to JPEG and then these images to PDF file using Aspose.Pdf for Java. Aspose.Pdf for Java is very well capable of dealing with TIFF images and can easily transform them into PDF format. However there are cases when a TIFF image contains frames with different resolution or page orientation and product might not work well. So in order to resolve such issues, we can first convert TIFF frames into individual JPEG images and then save these images into PDF format using Aspose.Pdf for Java. ]]>Thu, 23 Jan 2014 16:51:50 GMThttp://snipplr.com/view/73485/convert-each-tiff-frame-to-jpeg--transform-them-to-pdf-format-using-java/(Python) All-Or-Nothing Transform - weilaweihttp://snipplr.com/view/64825/allornothing-transform/
Performs an all-or-nothing transform on a stream of chunks. The data can only be decrypted if every block is present to generate an HMAC for. The list of HMACs is then XOR'd against the final block from the transform, yielding the decryption key for the blocks.
Reports a hash of the encrypted chunk for storage/retrieval without needing to calculate HMAC until decryption.
Needs a lot of cleanup and some fixes. Makes a lot of assumptions, for instance, that `current_block`, `total_blocks`, and `data_size` only occupy 1 byte apiece. Currently doesn't strip padding after decoding, and doesn't convert original integers for `current_block`, `total_blocks`, and `data_size` back from `bytes`. Does a ton of extra work (conversions between `bytes` and `bytearray`).
**NOTE**: I removed code that verified the HMACs of the final block and each encrypted block to simplify the code, because you already need the correct HMACs to get the block key from the final block, and the block hashes are taken of the blocks encrypted with the block key.
**NOTE 2**: The incrementing counter typically XOR'd with the plaintext blocks is actually prepended (`chunk() `returns blocks of the format `[current_block, total_blocks, data_size, data[a_block] (and for the last data block, + (padding_size * padding))]`.
**NOTE 3**: In this scheme, if you scatter the encrypted blocks, final blocks, lists of hashes of encrypted blocks and final blocks, and HMAC secret keys amongst a minimum of 4 parties, no single party can possibly decrypt the content, short of attacks on the encryption and hashing algorithms themselves, eavesdropping on other communications, impersonating another node (to acquire the other pieces illegitimately), etc.. Additionally, each node should be able to plausibly deny knowledge of the contents of their node, if they restrict their own access to the other necessary pieces.
The encrypted block server node has neither of the necessary keys to either decrypt the blocks or to derive their decryption key by generating their HMACs--even if it did, it would have no final blocks from which to recover the decryption key.
The final block server node has no encrypted blocks to decrypt, no awareness of which encrypted blocks belong to which final blocks, no HMAC secret key to derive the decryption key for the final block--and no encrypted blocks to perform an HMAC on.
The "location" server node has the regular hashes of the encrypted blocks and their corresponding final blocks (unless the file is secret). It has no HMAC secret key, nor the encrypted blocks, nor the final block or inner key. It could recover all but the HMAC secret key, so caution should be exercised with this node, for it should never come into possession of the HMAC secret key.
Finally, the one person who can recover the plaintext content should have the HMAC secret key and the hash of the list of hashes (of all blocks). To recover the plaintext, this person asks the location node for the list of hashes matching their hash. They then ask the encrypted block nodes for the blocks matching all but the last hash in the list. They perform an HMAC, using their secret key, on each of the blocks. They request the final block by its hash from the final block node, and XOR each HMAC with the final block, producing the block decryption key. Finally, they decrypt each block.
__This module does **not** demonstrate scattering the parts of an AONT.__ In this example, everything resides within the local machine, in the currently running process.
**NOTE 4**: I seem unable to swap any blocks (excluding the last blocks) and still maintain correct decryption. However, the block key decrypts correctly, so the HMACs must be generated correctly, despite not verifying them explicitly. From my understanding of the algorithm, I should be able to swap or shuffle the blocks (as they are encrypted separately) and still decrypt them. Ideas/corrections welcome.
**NOTE 5**: Dependencies:
- [PyCrypto](https://www.dlitz.net/software/pycrypto/)
- [`hmac`](http://snipplr.com/view/64824/hmac/)
- [`stream`](http://snipplr.com/view/64823/chunk-data-for-streaming/) ]]>Wed, 09 May 2012 05:10:32 GMThttp://snipplr.com/view/64825/allornothing-transform/(CSS) CSS3 Transform - Barlonhttp://snipplr.com/view/60759/css3-transform/
Supported in Chrome, Firefox, Safari and Opera (requiring vendor prefix) ]]>Sun, 13 Nov 2011 02:37:33 GMThttp://snipplr.com/view/60759/css3-transform/(ActionScript 3) AS3 Setting Colour of DisplayObject using ColorTransform - adrianparrhttp://snipplr.com/view/47558/as3-setting-colour-of-displayobject-using-colortransform/
]]>Thu, 20 Jan 2011 03:35:43 GMThttp://snipplr.com/view/47558/as3-setting-colour-of-displayobject-using-colortransform/(CSS) Use CSS transform for Interesting Hover Effects - alozuldohttp://snipplr.com/view/42842/use-css-transform-for-interesting-hover-effects/
For progressive enhancement, you could use the transform property that is supported by many browsers that have CSS3 support.
Here’s a trick for enlarging a elements on hover by 110%. ]]>Sun, 24 Oct 2010 10:04:10 GMThttp://snipplr.com/view/42842/use-css-transform-for-interesting-hover-effects/(Other) Make text net safe - anttihttp://snipplr.com/view/41149/make-text-net-safe/
]]>Wed, 29 Sep 2010 23:10:57 GMThttp://snipplr.com/view/41149/make-text-net-safe/(CSS) CSS3 Rotation - reynishhttp://snipplr.com/view/39903/css3-rotation/
On element:hover this will increase scale and rotate over .5 of a second.\r\n\r\nI borrowed it from somewhere else so thank them. ]]>Thu, 02 Sep 2010 19:40:42 GMThttp://snipplr.com/view/39903/css3-rotation/(CSS) Cross Browser CSS Gradients with Sass - viatroposhttp://snipplr.com/view/38963/cross-browser-css-gradients-with-sass/
]]>Thu, 12 Aug 2010 08:00:35 GMThttp://snipplr.com/view/38963/cross-browser-css-gradients-with-sass/(CSS) Cross Browser CSS Rotation with and without Sass - viatroposhttp://snipplr.com/view/38962/cross-browser-css-rotation-with-and-without-sass/
]]>Thu, 12 Aug 2010 07:58:33 GMThttp://snipplr.com/view/38962/cross-browser-css-rotation-with-and-without-sass/(Objective C) Straighten and Scale UIImage - aviddv1http://snipplr.com/view/35060/straighten-and-scale-uiimage/
Usage: [self straightenAndScaleImage:imageView.image andTheMaxDimension:100]; ]]>Sat, 22 May 2010 10:21:43 GMThttp://snipplr.com/view/35060/straighten-and-scale-uiimage/(ActionScript 3) AS3 Fit DisplayObject into Rectangle - adrianparrhttp://snipplr.com/view/28016/as3--fit-displayobject-into-rectangle/
DisplayUtils.as and Alignment.as
These two classes by Justin Windle (aka Soulwire) can be used to scale a DisplayObject to fit within (fill) a rectangle, without distorting the image.
Example Usage
Fit a DisplayObject into a Rectangle
var area:Rectangle = new Rectangle( 0, 0, 200, 100 );
DisplayUtils.fitIntoRect( myDisplayObject, area, true, Alignment.MIDDLE );
Create a fullscreen background image
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
function onStageResized( event:Event = null ):void
{
var area:Rectangle = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );
DisplayUtils.fitIntoRect( myDisplayObject, area, true, Alignment.MIDDLE );
}
stage.addEventListener( Event.RESIZE, onStageResized );
onStageResized();
Create a thumbnail
var thumb:Bitmap = DisplayUtils.createThumb( myBitmap.bitmapData, 100, 100, Alignment.MIDDLE, true );
addChild( thumb ); ]]>Tue, 09 Feb 2010 04:39:23 GMThttp://snipplr.com/view/28016/as3--fit-displayobject-into-rectangle/(ActionScript 3) From AS2 to AS3 – Where did it go – setRGB | [mck] - mhulsehttp://snipplr.com/view/27981/from-as2-to-as3--where-did-it-go--setrgb--mck/
I really like the use of constants and the dollar sign ($) in this class. I have only used $ in jQuery to designate objects. Looks like one might use $ in AS3 classes to designate/differentiate passed-in variables from internal method/global vars. ]]>Mon, 08 Feb 2010 20:29:40 GMThttp://snipplr.com/view/27981/from-as2-to-as3--where-did-it-go--setrgb--mck/(CSS) Rotate elements - marciohttp://snipplr.com/view/27764/rotate-elements/
]]>Fri, 05 Feb 2010 14:52:48 GMThttp://snipplr.com/view/27764/rotate-elements/(C#) How to use XSLT and C# to transform XML - victorbobahttp://snipplr.com/view/24270/how-to-use-xslt-and-c-to-transform-xml/
]]>Fri, 04 Dec 2009 10:22:47 GMThttp://snipplr.com/view/24270/how-to-use-xslt-and-c-to-transform-xml/(C#) Using XSLT to Transform XML Using C# ASP.NET - Meander365http://snipplr.com/view/18204/using-xslt-to-transform-xml-using-c-aspnet/
]]>Wed, 12 Aug 2009 05:54:58 GMThttp://snipplr.com/view/18204/using-xslt-to-transform-xml-using-c-aspnet/(C#) XSLT Helper class - mtelligenthttp://snipplr.com/view/17080/xslt-helper-class/
]]>Thu, 16 Jul 2009 15:41:12 GMThttp://snipplr.com/view/17080/xslt-helper-class/(PHP) PHP Paragrapher - iroybothttp://snipplr.com/view/14560/php-paragrapher/
Transform text (eg. from a WYSIWYG) into nicely formatted HTML paragraphs. (Credits: Ludo Magnocavallo's LightPress).
[this is a solid starting point - but a lot of HTML elements are missing] ]]>Wed, 29 Apr 2009 04:26:58 GMThttp://snipplr.com/view/14560/php-paragrapher/(PHP) Easy transform date format y-m-d => d-m-y on PHP - isaachttp://snipplr.com/view/5868/easy-transform-date-format-ymd--dmy-on-php/
This changes the date format from y-m-d to d-m-y on PHP ]]>Tue, 15 Apr 2008 14:42:47 GMThttp://snipplr.com/view/5868/easy-transform-date-format-ymd--dmy-on-php/(PHP) Easy transform date format y-m-d => d-m-y on PHP - isaachttp://snipplr.com/view/5867/easy-transform-date-format-ymd--dmy-on-php/
This changes the date format from y-m-d to d-m-y on PHP. It's easy to change the - to / or spaces... ]]>Tue, 15 Apr 2008 14:39:19 GMThttp://snipplr.com/view/5867/easy-transform-date-format-ymd--dmy-on-php/(PHP) Easy transform date format d-m-y => y-m-d on PHP - isaachttp://snipplr.com/view/5866/easy-transform-date-format-dmy--ymd-on-php/
This changes the date format from d-m-y to y-m-d on PHP. It's easy to change the - to / or spaces... ]]>Tue, 15 Apr 2008 14:34:11 GMThttp://snipplr.com/view/5866/easy-transform-date-format-dmy--ymd-on-php/