Skip to content

Instantly share code, notes, and snippets.

View acenkus's full-sized avatar
🇺🇦
SLAVA UKRAINI!!!

Aivaras acenkus

🇺🇦
SLAVA UKRAINI!!!
  • Mightmedia CMS
  • Vilnius, Lithuania
  • X @acenkus
View GitHub Profile
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@jjmu15
jjmu15 / in_viewport.js
Created January 27, 2014 10:19
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@maxrice
maxrice / wc-hide-coupons-cart-checkout.php
Created January 21, 2014 23:43
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
@SaLiVeR
SaLiVeR / update-checker.php
Created November 11, 2012 16:19 — forked from imjacobclark/update-checker.php
PHP Script Update Checker
<?php
/* Checks for updates using a remote CSV file
* The CSV must be like this
* versionnumber,versiondescription,type,downloadlink
* For the type, critical is 1 none critical is 0
* http://www.fusionstrike.com
*/
$version = "1"; //Version of the script, to check against CSV
$critical = FALSE; //Set Critical Variable to False
@zohararad
zohararad / classify.js
Created January 21, 2011 10:59
Simply OOP capabilities in vanilla Javascript
/**
* Classify.js
* A simple implementation of a Class native in Javascript with support for private and public methods and properties.
* Inspired by MooTools Class.js and by the Module Javascript design pattern (for private and public methods and properties)
*
* Zohar Arad. February 2011
*
* Usage:
*
* var MyClass = new Class({