Skip to content

Instantly share code, notes, and snippets.

View annalinneajohansson's full-sized avatar
🐱

Anna annalinneajohansson

🐱
  • Frontwalker Group AB
  • Sweden
  • 19:22 (UTC +02:00)
View GitHub Profile
@annalinneajohansson
annalinneajohansson / gist:19305c168af7510fd2e269731a052761
Created July 22, 2021 14:50
Dynamically / programmatically creating multi file upload field in Gravity Forms
When dynamically creating a fileupload field with multiple files option enabled
you must also run the gform_post_multifile_upload filter on the field for it to work properly
https://docs.gravityforms.com/gform_multifile_upload_field/
foreach ( $product_post_ids as $id ) {
$product = wc_get_product( $id );
$product->set_stock_status( 'instock' );
$product->set_manage_stock( 0 );
$product->save();
}
@annalinneajohansson
annalinneajohansson / gist:5b67e5926bf6350a69cb08ec9793c905
Last active February 8, 2020 01:38
Iterate Jpg images in folder and add Dropbox share link to csv
#!/bin/bash
rm -rf images.csv
for file in *; do
if [[ $file == *.jpg ]]
then
sharelink=$(dropbox sharelink "$file")
sharelink=${sharelink/dl=0/dl=1} ## replace dl=0 with dl=1 in the sharelinks
filename=$(basename "$file")
@annalinneajohansson
annalinneajohansson / getSimilarColor.js
Created September 8, 2016 11:01
Get similar color from a predefined sprectrum @link http://stackoverflow.com/a/8575671
function getSimilarColor ( color ) {
var base_colors=["660000","990000","cc0000","cc3333","ea4c88","993399","663399","333399","0066cc","0099cc","66cccc","77cc33","669900","336600","666600","999900","cccc33","ffff00","ffcc33","ff9900","ff6600","cc6633","996633","663300","000000","999999","cccccc","ffffff"];
//Convert to RGB, then R, G, B
var color_rgb = hex2rgb(color);
var color_r = color_rgb.split(',')[0];
var color_g = color_rgb.split(',')[1];
var color_b = color_rgb.split(',')[2];
//Create an emtyp array for the difference betwwen the colors
function __construct() {
parent::__construct( awsAccessKey, awsSecretKey );
$settings = get_option( 'op5dwnl_settings' );
$this->buckets = ( isset( $settings['buckets'] ) ) ? $settings['buckets'] : false;
add_filter( 'acf/load_field/name=amazon_s3_file', array( $this, 'acf_load_field' ) );
}
@annalinneajohansson
annalinneajohansson / provision.sh
Created May 25, 2016 13:40
Basic LAMP Vagrant provision script for Ubuntu servers
#!/usr/bin/env bash
# update / upgrade
sudo apt-get update > /dev/null 2>&1
sudo apt-get -y upgrade > /dev/null 2>&1
# Install Apache and PHP
sudo apt-get install -y apache2 php5 php5-curl > /dev/null 2>&1
# install mysql and give password to installer
<?php
$storeids = array();
foreach( $store_merchants as $merchantID ){
$storeid = get_user_meta( $merchantID, 'kostnadsstalle', true );
$storeids[$storeid] = $merchantID;
}
asort( $storeids );
$lastid = end( $storeids );
if ( 1 < count( $store_merchants ) ) {
@annalinneajohansson
annalinneajohansson / .htaccess
Last active November 18, 2019 09:55
# Attempt to load files from production if they're not in our local version. Adapted from: http://stevegrunwell.com/blog/keeping-wordpress-under-version-control-with-git
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^local.site\.com$
RewriteRule ^wp-content/uploads/(.*)$ https://production.site.com/wp-content/uploads/$1 [NC,L]
@annalinneajohansson
annalinneajohansson / default-install.sh
Last active January 3, 2016 21:18
my basic installs for ubuntu based distros. Make sure to activate “Canonical Partners” repos before running
#!/bin/sh
# Arc GTK theme
wget http://download.opensuse.org/repositories/home:Horst3180/xUbuntu_15.10/Release.key && sudo apt-key add - < Release.key &&
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/Horst3180/xUbuntu_15.10/ /' >> /etc/apt/sources.list.d/arc-theme.list"
# Grub Customizer
sudo add-apt-repository -y ppa:danielrichter2007/grub-customizer
# Nemo without Cinnamon dependencies
@annalinneajohansson
annalinneajohansson / .bashrc
Created November 29, 2015 10:11 — forked from marioBonales/.bashrc
Default .bashrc for ubuntu
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace