Skip to content

Instantly share code, notes, and snippets.

View patotoma's full-sized avatar
👍
what's up

Patrik Toma patotoma

👍
what's up
View GitHub Profile
@patotoma
patotoma / ContactForm.md
Last active October 7, 2023 07:39
secure php contact form

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 / AjaxContactForm.md
Last active July 25, 2023 02:41
Simple Asynchronous Contact Form with jQuery and PHP

Simple Ajax Contact Form with jQuery and PHP

Files:

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

Use:

@patotoma
patotoma / image-orientation.ts
Created May 22, 2019 05:25
Rotate image preview to compensate for EXIF orientation (Javascript / Typescript)
// 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 / InstantSearch.md
Created February 22, 2014 13:15
Instant Search and Order with AngularJS

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.
@patotoma
patotoma / SlideShow.md
Last active August 29, 2015 13:56
image slide show

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 August 29, 2015 13:56
Smooth Scroll with jQuery

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);
  });
};