Skip to content

Instantly share code, notes, and snippets.

View webkupas's full-sized avatar

Pavel Kookla webkupas

View GitHub Profile
@webkupas
webkupas / save-file-local.js
Created September 28, 2018 12:28 — forked from liabru/save-file-local.js
Save a text file locally with a filename, by triggering a download in JavaScript
/*
* Save a text file locally with a filename by triggering a download
*/
var text = "hello world",
blob = new Blob([text], { type: 'text/plain' }),
anchor = document.createElement('a');
anchor.download = "hello.txt";
anchor.href = (window.webkitURL || window.URL).createObjectURL(blob);
@webkupas
webkupas / difference.js
Created July 3, 2018 06:24 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@webkupas
webkupas / Fetch-API-cheat-sheet.md
Created March 27, 2018 15:43 — forked from jsdf/Fetch-API-cheat-sheet.md
Fetch API cheat sheet

fetch api cheat sheet

get JSON

fetch('/things/10', {
  credentials: 'same-origin',
  headers: {
    'accept': 'application/json'
  }
@webkupas
webkupas / app.vue
Created February 23, 2018 11:07 — forked from dohomi/app.vue
Small file input element based on vuetify
<template>
<file-input v-model="filename" @formData="formData">
<v-btn @click.native="uploadFiles">
</template>
<script>
import fileInput from './file-input.vue'
export default{
components:{fileInput}
@webkupas
webkupas / gist:adbe44a7b39895699fc1e7f837afac63
Created December 20, 2017 21:20 — forked from bergantine/gist:1165817
JavaScript hasClass(), addClass(), removeClass(). #javascript
// class manipulation from http://www.openjs.com/scripts/dom/class_manipulation.php
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
@webkupas
webkupas / functions.php
Created May 19, 2017 00:02 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@webkupas
webkupas / custom-search-acf-wordpress.php
Created April 11, 2017 11:27 — forked from fiskhandlarn/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. I updated this original script with better documentation and XSS / SQL injection support.
<?php
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
I also updated this work to include XSS and SQL injection projection
[list_searcheable_acf list all the custom fields we want to include in our search query]
@webkupas
webkupas / Re-Position-Yoast-SEO-plugin-metabox
Created February 27, 2017 15:21 — forked from jacobwise/Re-Position-Yoast-SEO-plugin-metabox
Re-position Yoast SEO plugin to high priority. Just change high to low to put it at the bottom.
/**
*
* Filter Yoast SEO Metabox Priority
* @author Jacob Wise
* @link http://swellfire.com/code/filter-yoast-seo-metabox-priority
*
*/
add_filter( 'wpseo_metabox_prio', 'jw_filter_yoast_seo_metabox' );
function jw_filter_yoast_seo_metabox() {
return 'high';