Skip to content

Instantly share code, notes, and snippets.

Avatar

Sami Hellsten Dropa

  • Tampere, Finland
View GitHub Profile
View updatenode.php
<?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) {
View inserter.cpp
#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 Nov 14, 2017
Why does this either open up every marker, or none
View all-or-nothing.js
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 Nov 13, 2017
proper way to do different submits
View propersubmit.php
<?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 Nov 13, 2017
How to identify submit from each other in same form
View submitidentifier.php
<?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.
*/
View UserCleanup.php
<?php
$users = \Drupal::entityQuery('user')
->execute();
$max = count($users);
$pointer = 0;
foreach (array_chunk($users, 100) as $chunk) {
foreach ($chunk as $user_id) {
$pointer++;