Skip to content

Instantly share code, notes, and snippets.

@cornelisonc
cornelisonc / InitCommand.php
Created April 5, 2024 17:21
maybeAddCustomCommands() deployer example
<?php
namespace DeployerCommands;
use Deployer\Command\InitCommand as ParentInit;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@cornelisonc
cornelisonc / after.php
Last active April 6, 2018 21:41
WordPress blog archive: featured image or dynamic random featured image
<div class="list-article-thumb">
<a href="<?php echo esc_url( get_permalink() ); ?>">
<?php
if ( has_post_thumbnail( ) ) {
the_post_thumbnail();
} else {
$images_iterator = new FilesystemIterator(
WP_CONTENT_DIR . '/themes/yourthemename/images/',
FilesystemIterator::SKIP_DOTS
);
@cornelisonc
cornelisonc / before.php
Created April 6, 2018 21:05
WordPress blog archive: featured image or static default image
<div class="list-article-thumb">
<a href="<?php echo esc_url( get_permalink() ); ?>">
<?php
if ( has_post_thumbnail( ) ) {
the_post_thumbnail();
} else {
echo '<img alt="" src="'. get_template_directory_uri() . '/images/placeholder.png' .'">';
}
?>
</a>
@cornelisonc
cornelisonc / getfiles
Created August 9, 2017 21:59
Bash Script to Download Files from GridFS
#!/bin/bash
while read -r line; do
file=$(echo "$line" | awk -F'\t' '{ print $1 }')
[[ $file == 'connecting to'* ]] && continue
file_id="$(cut -d'|' -f1 <<<"$file")"
file_key="$(cut -d'|' -f2 <<<"$file")"
mkdir $file_id && cd "$_"
mongofiles -d meteor --prefix="cfs_gridfs.filesStore" get_id 'ObjectId("'$file_key'")'
@cornelisonc
cornelisonc / gist:5671035
Last active December 17, 2015 20:58
Output
Ceilis-MacBook-Pro:colormyi ceili$ git push heroku master
Counting objects: 882, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (746/746), done.
Writing objects: 100% (882/882), 3.87 MiB | 536 KiB/s, done.
Total 882 (delta 49), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
@cornelisonc
cornelisonc / gist:5670980
Last active December 17, 2015 20:58
Spree gemfile
source "https://rubygems.org"
ruby "1.9.3"
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
@cornelisonc
cornelisonc / CustomNotification.php
Created June 6, 2012 16:29
Ecwid Notification Script
<?php
//Store specific variables for the URL
$secretKey = "YourSecretKey";
$storeId = YourNumericalStoreId;
//This is declaring variables for the notification mail function
$subject = "Notification Subject";
$mailheader = "From: someone@yourwebpage.com \r\n";
@cornelisonc
cornelisonc / show-tables-with-prefix.sql
Created May 19, 2015 17:36
MySQL show table names like or not like prefix
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'databasename'
AND table_name LIKE 'prefix%';
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'databasename'
AND table_name NOT LIKE 'prefix%';
@cornelisonc
cornelisonc / create-file-product-association-script.php
Created May 16, 2015 21:21
Generate SQL insert statements to associate products with downloadable files
<?php
function csv_to_array($filename='', $delimiter=',')
{
if(!file_exists($filename) || !is_readable($filename))
return FALSE;
$header = NULL;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE)
{
@cornelisonc
cornelisonc / entity_id-product_name.sql
Last active August 29, 2015 14:21
Get entity_id and name of products in Magento db. Don't forget your table prefix!
select cpev.entity_id as entity_id, cpev.value as product_name from catalog_product_entity_varchar as cpev
join eav_attribute as ea on cpev.attribute_id = ea.attribute_id
join eav_entity_type as eet on ea.entity_type_id = eet.entity_type_id
join catalog_product_entity as cpe on cpe.entity_id = cpev.entity_id
where ea.attribute_code = 'name'
and eet.entity_type_code = 'catalog_product'
and cpe.type_id = 'downloadable';