Skip to content

Instantly share code, notes, and snippets.

Avatar

Anna annalinneajohansson

View GitHub Profile
View gist:8d9342579feb4d8a2ce15fd83446ad21
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 Feb 8, 2020
Iterate Jpg images in folder and add Dropbox share link to csv
View gist:5b67e5926bf6350a69cb08ec9793c905
#!/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")
View getSimilarColor.js
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
View gist:52c60b28eeb7923340baae1bb5707c37
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
Basic LAMP Vagrant provision script for Ubuntu servers
View provision.sh
#!/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
View gist:c9abd92438c8dc19ea7b
<?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 Nov 18, 2019
# 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
View .htaccess
# 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 Jan 3, 2016
my basic installs for ubuntu based distros. Make sure to activate “Canonical Partners” repos before running
View default-install.sh
#!/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 Nov 29, 2015 — forked from marioBonales/.bashrc
Default .bashrc for ubuntu
View .bashrc
# ~/.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
View WP_Widget.php
<?php
class My_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'my-widget',
'description' => __( 'My Widget description', 'textdomain' ),
);
$this->WP_Widget( 'My_Widget', __( 'My Widget title', 'textdomain' ), $widget_ops );
}
You can’t perform that action at this time.