Skip to content

Instantly share code, notes, and snippets.

@sadiefp
sadiefp / Dockerfile
Created January 18, 2022 19:43
Install Terminus in Dockerfile
# This is what we added to Node Docker image to install Terminus
# Install everything we need from php
RUN apk add curl
RUN apk add php
RUN apk add php-cli
RUN apk add php-json
RUN apk add php-phar
RUN apk add php-iconv
RUN apk add php-mbstring
@sadiefp
sadiefp / example.install
Last active September 22, 2017 20:53
hook_update() to create photo nodes out of untracked files
/**
* Move files from files dir & add image node.
*/
function hook_update_N(&$sandbox) {
if (!isset($sandbox['progress'])) {
$sandbox['progress'] = 0;
$sandbox['current_nid'] = 0;
$sandbox['max'] = db_query("SELECT COUNT(entity_id) FROM {field_data_field_body} WHERE field_body_value LIKE '%src=\"https://www.example.com/sites/default/files/%'")->fetchField();
$sandbox['messages'] = array();
$sandbox['csv'] = array();
@sadiefp
sadiefp / gist:0a199a583ebc09190a6124255fad6cfc
Last active September 22, 2017 20:21
Bash script to move files with no extension into folders
#!/bin/bash
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
FILES=${parent_path}/files/*
counter=0
for f in $FILES
do
if [ -f "$f" ]; then
file=${f##*/}
if [[ ${file} != *"."* ]]; then
if [[ "$counter" -lt 2499 ]]; then
@sadiefp
sadiefp / gist:3cd1b6d4e53f39a41aabc52217182f36
Created September 22, 2017 20:20
Bash script to move files with no extension into a folder.
#!/bin/bash
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
FILES=${parent_path}/files/*
counter=0
for f in $FILES
do
if [ -f "$f" ]; then
file=${f##*/}
if [[ ${file} != *"."* ]]; then
if [[ "$counter" -lt 2499 ]]; then