Skip to content

Instantly share code, notes, and snippets.

👍
what's up

Patrik Toma patotoma

👍
what's up
Block or report user

Report or block patotoma

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@patotoma
patotoma / image-orientation.ts
Created May 22, 2019
Rotate image preview to compensate for EXIF orientation (Javascript / Typescript)
View image-orientation.ts
// Based on: https://stackoverflow.com/a/46814952/283851
/**
* Create a Base64 Image URL, with rotation applied to compensate for EXIF orientation, if needed.
*
* Optionally resize to a smaller maximum width - to improve performance for larger image thumbnails.
*/
export async function getImageUrl(file: File, maxWidth?: number) {
return readOrientation(file)
.then(orientation => applyRotation(file, orientation || 1, maxWidth || 999999));
@patotoma
patotoma / AjaxContactForm.md
Last active Dec 15, 2019
Simple Asynchronous Contact Form with jQuery and PHP
View AjaxContactForm.md

Simple Ajax Contact Form with jQuery and PHP

Files:

  • index.html
  • style.css
  • js.js
  • mailer.php

Use:

@patotoma
patotoma / InstantSearch.md
Created Feb 22, 2014
Instant Search and Order with AngularJS
View InstantSearch.md

Instant Search and Order with AngularJS

How to use:

  • Download instantSearch.html or just copy the code.
  • Add the file to your webpage directory.
  • Edit to suit your needs.

Working fiddle

@patotoma
patotoma / ContactForm.md
Last active Dec 1, 2019
secure php contact form
View ContactForm.md

Secured PHP Contact Form

<?php
  if(isset($_POST['submit'])){
    $name = htmlspecialchars(stripslashes(trim($_POST['name'])));
    $subject = htmlspecialchars(stripslashes(trim($_POST['subject'])));
    $email = htmlspecialchars(stripslashes(trim($_POST['email'])));
    $message = htmlspecialchars(stripslashes(trim($_POST['message'])));
    if(!preg_match("/^[A-Za-z .'-]+$/", $name)){
@patotoma
patotoma / SlideShow.md
Last active Aug 29, 2015
image slide show
View SlideShow.md

Image Slide Show with jQuery

$.fn.slideShow = function(fadeIn, fadeOut, duration){
  var list = this;
  var ID = setInterval(function(){
    var visible = $(list).find('li:visible');
    $(visible).fadeOut(fadeOut);
    if($(visible).is(':last-child')){
      $(list).find('li:first').fadeIn(fadeIn);
@patotoma
patotoma / SmoothScroll.md
Last active Aug 29, 2015
Smooth Scroll with jQuery
View SmoothScroll.md

Smooth Scroll with jQuery

$.fn.smoothscroll = function(offset, speed){
  $(this).find('a').on('click', function(e){
    e.preventDefault();
      $('html,body').animate({scrollTop: $(this.hash).offset().top - offset}, speed);
  });
};
You can’t perform that action at this time.