Skip to content

Instantly share code, notes, and snippets.

View Tusko's full-sized avatar

Tusko Trush Tusko

View GitHub Profile
@Tusko
Tusko / loadPosts.js
Last active December 2, 2017 01:40 — forked from moskalukigor/functions.php
Wordpress Ajax
//JS
var ajaxcontent = $('.products');
$.ajax({
type: 'POST',
url: window.wp_data.ajax_url,
data: {
action: "loadPosts",
},
success: function (html) {
@Tusko
Tusko / jquery.ajax.js
Last active November 12, 2021 02:54
$.ajax Promise
/*
* ajax Defaults (optional):
$.ajaxSetup({
type : 'POST',
dataType : 'json',
cache : true,
global : true,
data : {},
contentType : 'application/json',
beforeSend : function (xhr) {
@Tusko
Tusko / cr2-to-jpg.sh
Created June 22, 2017 04:48
RAW 2 JPG Converter
for i in *.CR2; do sips -s format jpeg $i --out "${i%.*}.jpg"; done
@Tusko
Tusko / colors.json
Last active January 31, 2018 11:16
parse tax from json
[
{
"name": "IndianRed",
"color": "#CD5C5C"
},
{
"name": "LightCoral",
"color": "#F08080"
},
{
@Tusko
Tusko / jquery-visible.js
Created March 19, 2017 20:43
Check if element is visible (in viewport(
(function($) {
$.fn.visible = function(partial, hidden) {
var $t = $(this).eq(0),
t = $t.get(0),
$w = $(window),
viewTop = $w.scrollTop(),
viewBottom = viewTop + $w.height(),
_top = $t.offset().top,
<svg>
<linearGradient y2="0.5" x2="1" id="textGradient" spreadMethod="repeat" x1="0" y1="0.5">
<stop stop-color="#802b78" offset="0"></stop><stop stop-color="#ef4036" offset="1"></stop>
</linearGradient>
<text style="fill: url(#textGradient);" y="1em">Sklepy i usługi</text>
</svg>
@Tusko
Tusko / cookie.js
Created February 6, 2017 09:47
Cookie vanilla-js
@Tusko
Tusko / eba.sh
Created January 22, 2017 10:31
Wordpress permissions / Terminal commands
find . -type f -exec chmod 644 {} +
find . -type d -exec chmod 755 {} +
#fix for wp-config.php and index.php
find . -name "wp-config.php" -exec chmod 444 {} +
@Tusko
Tusko / functions.php
Created December 7, 2016 13:57 — forked from moskalukigor/functions.php
scheduler wp
add_action('init', 'apiSynchronization_activation');
function apiSynchronization_activation(){
if ( !wp_next_scheduled( 'apiSynchronization' ) ) {
wp_schedule_event( time(), 'twicedaily', 'apiSynchronization');
}
}
add_action('apiSynchronization', 'apiSync', 100);
function apiSync()
{
@Tusko
Tusko / tmp.php
Last active October 28, 2016 12:23
instagram + FB timeline
<?php
/**
Instagram API
*/
function instagram_user_ID($username, $client_id, $token){
$ins_id = get_transient( 'instagram_userid' );
if ( false === $ins_id || empty($ins_id) ) {
$url = 'https://api.instagram.com/v1/users/search?q=' . $username . '&client_id=' . $client_id .'&access_token=' . $token;
$api = wp_remote_get( $url );
$data = json_decode($api['body']);