Skip to content

Instantly share code, notes, and snippets.

@crittermike
crittermike / import.php
Last active August 11, 2023 10:39
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
@roadrunner2
roadrunner2 / 0 Linux-On-MBP-Late-2016.md
Last active July 26, 2024 23:34
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@seutje
seutje / Paranoia-escape-js.php
Created January 15, 2016 14:34
PHP helper function to escape javascript strings like a true paranoid mofo
<?php
/**
* Extremely paranoid escaping function for use with inline JS strings.
*
* Escapes every single character to a \x# format.
*
* @param string
*
* @return string
@duellsy
duellsy / import.py
Last active October 2, 2019 12:58 — forked from kbl/import.py
Import tasks and notes from wunderlist dump to todoist (and mark completed tasks as completed)
# -*- coding: utf8 -*-
import json
import urllib2
import urllib
import sys
import os
from argparse import ArgumentParser
from collections import defaultdict
<?php
$headers = array();
foreach ($xml->ROW->children() as $field) {
$headers[] = $field->getName();
}
$csv_filename = str_replace('xml', 'csv', $filename);
$file = $this->getCsvDirectory() . '/' . $csv_filename;
if (file_exists($file)) {
@mderazon
mderazon / export-to-csv.gs
Last active April 2, 2024 22:25
Google apps script to export to individual csv files all sheets in an open spreadsheet
/*
* script to export data in all sheets in the current spreadsheet as individual csv files
* files will be named according to the name of the sheet
* author: Michael Derazon
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "export as csv files", functionName: "saveAsCSV"}];
ss.addMenu("csv", csvMenuEntries);
@swarminglogic
swarminglogic / watchfile.sh
Last active March 4, 2024 14:44
watchfile - monitor file(s) and execute a command when files are changed
#!/bin/bash
version=1.0.1
versionDate="2014-02-14"
function showHelp() {
echo "watchfile - monitor file(s)/command and perform action when changed
Possible ways of usage
----------------------------------------
@opi
opi / gist:5335785
Last active April 28, 2020 18:27
Drupal 7 : Add translation programmatically
<?php
$report = array(
'skips'=>0,
'updates'=>0,
'deletes'=>0,
'additions'=>0
); // ??
$source = "Sometime drupal sucks";
$translation = "Drupal C DLA BALLE";
@sgergely
sgergely / gist:3793166
Created September 27, 2012 09:43
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@sprice
sprice / default_images.php
Created March 8, 2012 19:54
Provide image field default images in Drupal 7
<?php
// General function in base feature or custom module.
/**
* Return a file object after saving a default image and storing the fid
* in a variable.
*
* @param $default_image
* An associative array containing: