Skip to content

Instantly share code, notes, and snippets.

View Dropa's full-sized avatar

Sami Hellsten Dropa

  • Tampere, Finland
View GitHub Profile
<?php
$entityTypeManager = \Drupal::entityTypeManager();
$storage = $entityTypeManager->getStorage('node');
// Replace <article> with your nodetype.
$query = $storage->getQuery()
->condition('type', 'article')
->execute();
// Chunk in case you have thousands of nodes to update.
foreach (array_chunk($query, 200) as $chunk) {
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
using std::set;
using std::string;
using std::cin;
@Dropa
Dropa / all-or-nothing.js
Created November 14, 2017 21:02
Why does this either open up every marker, or none
import React from "react"
const fetch = require("isomorphic-fetch");
const { compose, withProps, withHandlers, withStateHandlers } = require("recompose");
const demoFancyMapStyles = require("./demoFancyMapStyles.json");
const FaAnchor = require("react-icons/lib/fa/anchor");
const {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
@Dropa
Dropa / propersubmit.php
Created November 13, 2017 11:57
proper way to do different submits
<?php
namespace Drupal\general\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* List tests arranged in groups that can be selected and run.
*/
@Dropa
Dropa / submitidentifier.php
Last active November 13, 2017 11:52
How to identify submit from each other in same form
<?php
namespace Drupal\general\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* List tests arranged in groups that can be selected and run.
*/
<?php
$users = \Drupal::entityQuery('user')
->execute();
$max = count($users);
$pointer = 0;
foreach (array_chunk($users, 100) as $chunk) {
foreach ($chunk as $user_id) {
$pointer++;