Skip to content

Instantly share code, notes, and snippets.

Avatar

Ceili Cornelison cornelisonc

View GitHub Profile
@cornelisonc
cornelisonc / generate-file-dirs.php
Last active Aug 29, 2015
Create file directory structure for downloadable Magento products & move files accordingly
View generate-file-dirs.php
<?php
foreach (new DirectoryIterator('files/') as $file) {
if ($file->isFile()) {
$file_name = $file->getFilename();
$name = strtolower($file_name);
$letter1 = $name[0];
$letter2 = $name[1];
// Create first directory
if (!file_exists('media/downloadable/files/links/' . $letter1)) {
@cornelisonc
cornelisonc / create-file-product-association-script.php
Created May 16, 2015
Generate SQL insert statements to associate products with downloadable files
View create-file-product-association-script.php
<?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 Aug 29, 2015
Get entity_id and name of products in Magento db. Don't forget your table prefix!
View entity_id-product_name.sql
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';
@cornelisonc
cornelisonc / show-tables-with-prefix.sql
Created May 19, 2015
MySQL show table names like or not like prefix
View show-tables-with-prefix.sql
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 / CustomNotification.php
Created Jun 6, 2012
Ecwid Notification Script
View CustomNotification.php
<?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";
View gist:5670980
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
View gist:5671035
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 / getfiles
Created Aug 9, 2017
Bash Script to Download Files from GridFS
View getfiles
#!/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 / before.php
Created Apr 6, 2018
WordPress blog archive: featured image or static default image
View before.php
<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 / after.php
Last active Apr 6, 2018
WordPress blog archive: featured image or dynamic random featured image
View after.php
<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
);