Skip to content

Instantly share code, notes, and snippets.

View yunusga's full-sized avatar
👋
Hello World!

Yunus Gaziyev yunusga

👋
Hello World!
View GitHub Profile
@yunusga
yunusga / wpcf7.js
Created July 5, 2019 06:46
Scroll to first invalid field on Contact Form 7 validation error event
/**
* Scroll to first invalid field
* WPCF7 on validation error event
*/
document.addEventListener( 'wpcf7invalid', function( event ) {
setTimeout( function() {
$('html').stop().animate({
scrollTop: $('.wpcf7-not-valid').eq(0).offset().top - 140,
}, 500, 'swing');
}, 100);
@infusion
infusion / import-tar-gz.sh
Last active May 4, 2023 06:00
Import a tar.gz file to MySQL
tar xOf dump.sql.tar.gz | mysql -u $user -p $database
@jbmoelker
jbmoelker / nunjucks-filter-limit-to.js
Created March 21, 2014 19:12
Nunjucks limitTo filter. Creates a new array or string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array or string, as specified by the value and sign (positive or negative) of limit.
/**
* @module limitTo
*
* Creates a new array or string containing only a specified number of elements.
* The elements are taken from either the beginning or the end of the source array
* or string, as specified by the value and sign (positive or negative) of limit.
*
* Same behavior as AngularJS limitTo filter: http://docs.angularjs.org/api/ng/filter/limitTo
*
* To use this filter in a template, first register it in the Nunjucks environment:
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noodp, noydir" />
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<link rel="canonical" href="http://mysite.com/" />
<link rel="stylesheet" href="http://mysite.com/style.css" type="text/css" />
@takien
takien / youtubeID.js
Last active April 13, 2024 16:19
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@juanmhidalgo
juanmhidalgo / visibly.js
Created September 27, 2012 10:21 — forked from addyosmani/visibly.js
Cross-browser Page Visibility API polyfill
/*!
* isVis - v0.5.6 Sep 2012 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*/
/*
* Firefox support added based on https://developer.mozilla.org/en-US/docs/DOM/Using_the_Page_Visibility_API
* @juanmhidalgo
*/