Skip to content

Instantly share code, notes, and snippets.

@joniahola
joniahola / setup-acf.php
Created February 23, 2021 16:02
Create translations to original post (duplicate data). (Wordpress + Polylang)
add_filter('acf/save_post' , function($post_id) {
//only want to modify events
if(get_post_type($post_id) === 'event') {
$post = get_post($post_id);
$langs = ['en', 'fi', 'sv'];
$currentLang = pll_current_language();
$pagetranslations = [];
for($i = 0; $i < count($langs); $i++) {
if($langs[$i] == $currentLang) {
@joniahola
joniahola / functions.php
Created September 23, 2019 12:17
core block muokkaus
<?php
add_filter( 'render_block', 'my_wrap_quote_block_fitler', 10, 3);
function my_wrap_quote_block_fitler( $block_content, $block ) {
$listOfExtraContainer = [
'core/paragraph',
'core/image',
'core/heading',
'core/gallery',
@joniahola
joniahola / gulpfile.js
Last active April 7, 2019 15:26
Sync between local and remote files using gulp. Developing your local machine and upload all changes to remote server. Just run `npm install`, fill property fields to `.settings.json` and run `gulp watch`. Tested node v8.7.0
const gulp = require('gulp'); //Example version ~3.9.1
const watch = require('gulp-watch'); //Used plugin because it's better. Example version ^5.0.1
const sftp = require('gulp-sftp'); //Example version ^0.1.5
const GulpSSH = require('gulp-ssh'); //Example version ^0.7.0
const fs = require('fs');
const settings = require('./.settings.json'); //credentials hide there
const sftpConfig = {
host: settings.host,
user: settings.user,
@joniahola
joniahola / css refresh bookmark
Last active October 26, 2018 11:40
Reload current page's stylesheets again (obiviosly not inline styles)
Chrome
---
1. Go to chrome://bookmarks/
2. Add new bookmark
3. add this code:
javascript:{let e=(e,t=document)=>Array.from(t.querySelectorAll(e)),t=r=>{for(let t of e('link[rel=stylesheet][href]',r)){let e=new URL(t.href);e.searchParams.set('forceReload',Date.now()),t.href=e}for(let o of e('iframe',r))o.contentDocument&&t(o.contentDocument)};t()}
4. Now you can refresh current page stylesheets!
@joniahola
joniahola / rAF.js
Last active August 29, 2015 14:27 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
function checkAnimationFrame() {
var lastTime = 0;
@joniahola
joniahola / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@joniahola
joniahola / css_resources.md
Last active August 29, 2015 14:19 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@joniahola
joniahola / javascript_resources.md
Last active August 29, 2015 14:19 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@joniahola
joniahola / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@joniahola
joniahola / youtubeplaylist.html
Created February 3, 2013 22:56
Simple youtube playlist-player. Only need to know youtube playlist url and insert to get-parameter 'url'. I found basic logic to find videos (if I remimber right) in this script snip: https://gist.github.com/906313
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<!-- Made by: Joni Ahola, 2012 -->
<!-- Easily embed youtube playlist: just add GET-parameter 'url' and youtube-playlist url -->
<!-- Example: filename.html?url=http://www.youtube.com/playlist?list=PLE5C2870574BF4B06 -->
<head profile="http://gmpg.org/xfn/11">
<style type="text/css">
/* placeholder inline styles */