Skip to content

Instantly share code, notes, and snippets.

View BramDriesen's full-sized avatar
:shipit:
On it!

Bram Driesen BramDriesen

:shipit:
On it!
View GitHub Profile
@BramDriesen
BramDriesen / drupal_load_single_field_from_entity.php
Last active October 28, 2017 10:13
Load a single field of an entity.
<?php
// Save the original field collection data.
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'commerce_product')
->entityCondition('bundle', $entity->type)
->propertyCondition('product_id', $entity->product_id);
$result = $query->execute();
if (isset($result['commerce_product'])) {
$original_product = $result['commerce_product'];
@BramDriesen
BramDriesen / drupal_save_single_field
Last active October 28, 2017 10:13
Save a single field value of an entity/node
<?php
$node = node_load(1); // 1 is node id we want to load
// Change field value
$node->field_product_description[$node->language][0]['value'] = 'This is a very nice and useful product. Buy it now! We want your money!';
// Get the numeric id of your field by passing field name
$info = field_info_field('field_product_description');
$fields = array($info['id']);
# D7 Search API Solr or apachesolr.module
drush --uri=[domain] ev '
// Get Solr.
function XX_get_solr() {
$solr = false;
if (function_exists("apachesolr_get_solr")) {
// apachesolr.module
$solr = apachesolr_get_solr();
}
elseif (function_exists("search_api_server_load")) {
echo 'flush_all' | nc localhost 11211
@BramDriesen
BramDriesen / link
Created December 11, 2017 13:18
URL to load the login page of a hotspot in case it doesn't auto-load.
sudo apt-get install curl
curl -O https://bin.equinox.io/c/mvjh5YAmwCZ/cryptotrader-stable-linux-amd64.tgz
tar -xvzf cryptotrader-stable-linux-amd64.tgz -C /usr/local/bin/
@BramDriesen
BramDriesen / strings_translations_hook_update_N.php
Created October 4, 2018 15:00 — forked from citlacom/strings_translations_hook_update_N.php
Programmatically set strings translations in hook_update_N()
/**
* Implements hook_update_N().
*/
function hook_update_N(&$sandbox) {
$report = array(
'skips' => 0,
'updates' => 0,
'deletes' => 0,
'additions' => 0
);
@BramDriesen
BramDriesen / delete_git_submodule.md
Created October 15, 2018 15:49 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@BramDriesen
BramDriesen / RPI Chromium kiosk 2018.txt
Created November 19, 2018 20:14
RPI Chromium kiosk 2018
# Always keeps on changing =).
https://blog.gordonturner.com/2017/12/10/raspberry-pi-full-screen-browser-raspbian-december-2017/
https://www.raspberrypi.org/forums/viewtopic.php?t=167645
https://raspberrypi.stackexchange.com/questions/42633/raspberry-pi-autostart-of-lxde-does-not-work
@BramDriesen
BramDriesen / one_line_public_key_copy.bash
Created December 12, 2018 09:40
One line command to copy your public ssh key
cat ~/.ssh/id_rsa.pub | pbcopy