Skip to content

Instantly share code, notes, and snippets.

View PauliusKrutkis's full-sized avatar

Pako PauliusKrutkis

  • Panevėžys
View GitHub Profile
@PauliusKrutkis
PauliusKrutkis / copy_tables.php
Created August 1, 2018 06:42
Copy paste tables from one database to another with php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$query = '';
$source = 'database_one';
$destination = 'database_two';
$tables = [
'table_one',
@PauliusKrutkis
PauliusKrutkis / script.js
Created November 19, 2017 19:05
jQuery range dropdown
var RangeDropdown = function () {
var $from, $to, $el, data;
function create($element) {
$el = $element;
data = $el.data('range-dropdown');
$from = $(data.from);
$to = $(data.to);
@PauliusKrutkis
PauliusKrutkis / tooltip.js
Created November 5, 2017 19:30
Javascript - change div position to hovered div center
var $tooltip = $('.tooltip');
$('.box').mouseenter(function () {
var $this = $(this);
var offset = $this.offset();
var width = $this.width();
var height = $this.height();
var centerX = offset.left + width / 2;
var centerY = offset.top + height / 2;
@PauliusKrutkis
PauliusKrutkis / index.html
Last active November 4, 2017 16:40
Radial animation button
<!-- no-animation class is required -->
<!-- set data-circle with a value for either a complete or half animation: -->
<!-- 1 - for complete -->
<!-- 0 - for half -->
<a class="button-circle no-animation" data-circle="1" href="#">1</a>
@PauliusKrutkis
PauliusKrutkis / scroll.js
Created November 1, 2017 19:51
Javascript - element scroll to middle
var $ = jQuery;
// make sure your element has overflow set
var $element = $('[data-scroll-box]');
$element.scrollTop('1000000');
$element.scrollLeft('1000000');
var scrollHeight = $element.prop('scrollHeight');
var scrollWidth = $element.prop('scrollWidth');
@PauliusKrutkis
PauliusKrutkis / DefaultController.php
Last active October 8, 2017 18:25
Symfony - simple 301 redirects setup
<?php
public function catchallAction($req)
{
$redirects = Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/redirects.yml'));
if (isset($redirects[$req])) {
return new RedirectResponse('/' . $redirects[$req], 301);
}
@PauliusKrutkis
PauliusKrutkis / set-image.php
Created July 6, 2017 13:35
Wordpress set post thumbnail with media_sideload_image function
<?php
require_once(ABSPATH . 'wp-admin/includes/media.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/image.php');
$url = 'http://wordpress.org/about/images/logos/wordpress-logo-stacked-rgb.png';
$title = "Anything you want";
$postId = 1;
@PauliusKrutkis
PauliusKrutkis / isElementInViewport.js
Created May 31, 2017 19:04
jQuery check if element is visible in view port
function isElementInViewport (el) {
if (typeof jQuery === "function" && el instanceof jQuery) {
el = el[0];
}
var rect = el.getBoundingClientRect();
return (
(rect.top + rect.height) >= 0 &&
@PauliusKrutkis
PauliusKrutkis / examples.sass
Created March 13, 2017 18:54
Various css (sass) examples
/*------------------------------------*\
#RESPONSIVE STICKY FOOTER
/*------------------------------------*/
html,
body
display: table
height: 100%
width: 100%
@PauliusKrutkis
PauliusKrutkis / button-waves.html
Created March 13, 2017 18:43
Button wave animation, inspired by material design
<button type="button" class="waves button" name="button">Button</button>
<style media="screen">
@keyframes ripple {
100% {
transform: scale(2);
opacity: 0;
}
}