Skip to content

Instantly share code, notes, and snippets.

Avatar
👍
what's up

Patrik Toma patotoma

👍
what's up
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 26, 2020
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 Oct 19, 2021
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);
  });
};