Skip to content

Instantly share code, notes, and snippets.

View unnamedfeeling's full-sized avatar

Oleksandr Yarosh unnamedfeeling

View GitHub Profile
$(document).on('click', 'a[href^="#"].js-ancor', function (event){
event.preventDefault();
var id=$(this).attr('href');
$('html, body').animate({
scrollTop: $(id).offset().top-$('header').innerHeight()-20
}, 1000);
});
@unnamedfeeling
unnamedfeeling / functions.php
Last active October 6, 2017 21:41
Woocommerce ajax add to cart
// ajax add to cart
function generic_ajax_add_to_cart() {
global $woocommerce;
$params=$_POST['params'];
// die(json_encode( $params ));
$prid = $params['prodid'];
$qty = $params['quant'];
// $var = $params['variation'];
@unnamedfeeling
unnamedfeeling / functions.php
Created October 6, 2017 21:46
Ajax get posts with js
function generic_ajax_posts(){
$params=$_POST
$offset=$params['params']['p']*((!empty($params['params']['q'])) ? $params['params']['q'] : 4);
$post_type=$params['params']['pt'];
$catid=(!empty($params['params']['cat']))?$params['params']['cat']:null;
$tpl=(!empty($params['params']['tpl']))?$params['params']['tpl']:null;
$args=array(
'post_type'=>$post_type,
'posts_per_page'=>4,
'offset'=>$offset
@unnamedfeeling
unnamedfeeling / hosts_setup.sh
Created November 15, 2017 10:25
Bash script for stripping out many adverts on the net (in addition to adblock and ghostery). Applicable for routers or linux distros.
rm /etc/hosts
wget http://winhelp2002.mvps.org/hosts.txt -q -O ->> /opt/etc/hosts
wget http://hosts-file.net/ad_servers.txt -q -O ->> /opt/etc/hosts
wget "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" -q -O ->> /opt/etc/hosts
sed -i 's/127.0.0.1/0.0.0.0/g' /opt/etc/hosts
ln -s /opt/etc/hosts /etc/hosts
killall dnsmasq
dnsmasq
@unnamedfeeling
unnamedfeeling / scripts.js
Created December 11, 2017 19:44
get and append additional data to wpcf7
// working with get params
function getSearchParameters() {
var prmstr = window.location.search.substr(1);
return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
}
function transformToAssocArray( prmstr ) {
var params = {};
var prmarr = prmstr.split("&");
for ( var i = 0; i < prmarr.length; i++) {
@unnamedfeeling
unnamedfeeling / .htaccess
Created January 25, 2018 22:46
htaccess ssl redirect
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://it-legal.pro/$1 [R,L]
@unnamedfeeling
unnamedfeeling / wistia.html
Last active January 26, 2018 16:50
Lazy wistia embed - will load nasty wistia scripts only when needed! + scripts lazyloader
<script>
// this one might go anywhere in your code
// inline it to get best results
loadscripts=function(arr){
!function(e,t,r){function n(){for(;d[0]&&"loaded"==d[0][f];)c=d.shift(),c[o]=!i.parentNode.insertBefore(c,i)}for(var s,a,c,d=[],i=e.scripts[0],o="onreadystatechange",f="readyState";s=r.shift();)a=e.createElement(t),"async"in i?(a.async=!1,e.head.appendChild(a)):i[f]?(d.push(a),a[o]=n):e.write("<"+t+' src="'+s+'" defer></'+t+">"),a.src=s}(document,"script",arr)
};
// loader end
// this one is for attaching event to your play button and load scripts
$(document).on('click', '.js-wistia-placeholder .playbtn', function(event){
var cont=$(this).parent();
@unnamedfeeling
unnamedfeeling / deploy_zoneminder.sh
Created April 2, 2018 16:24 — forked from g3rhard/deploy_zoneminder.sh
Install ZoneMinder with h264 archive storage
#!/bin/bash
# http://zoneminder.readthedocs.io/en/latest/installationguide/ubuntu.html#easy-way-ubuntu-16-04
#Задаем пароль для пользователя root для MySQL
COOKIES_PASSWORD="PASSWORD"
#Задаем часовой пояс для PHP
TIMEZONE="Asia/Irkutsk"
# Настраививаем автоматический ввод пароля для админа mysql.
@unnamedfeeling
unnamedfeeling / watchdog.sh
Created May 7, 2018 07:18 — forked from vodolaz095/watchdog.sh
watchdog.sh script for checking server running not mine, i stole it)
#!/bin/bash
# Service watchdog script
# Put in crontab to automatially restart services (and optionally email you) if they die for some reason.
# Note: You need to run this as root otherwise you won't be able to restart services.
#
# Example crontab usage:
#
# Strict check for apache2 service every 5 minutes, pipe results to /dev/null
# */5 * * * * sh /root/watchdog.sh apache2 "" > /dev/null
#
<!--
Email template: student/purchase_notification
Description: This email is sent to a student when they enroll in a course.
-->
<!-- Email Title -->
<div class="header-title">
<h1>{{text.email_receipts.thank_you_for_enrolling_in }} {{sale.course.name }}</h1>
</div>