Skip to content

Instantly share code, notes, and snippets.

View kehh's full-sized avatar

Kehan Harman kehh

View GitHub Profile
FROM alpine
RUN apk add bash \
bsd-compat-headers \
build-base \
linux-headers \
ncurses-dev \
readline-dev \
sqlite-dev \
zlib-dev \
@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');
@Pamblam
Pamblam / Oracle To Mysql Geometry Conversion.php
Last active April 20, 2023 06:22
Convert Oracle Spatial to MySQL Spatial
<?php
/**
* Convert an Oracle SYS.SDO_GEOMETRY definition (perhaps extracted from an insert
* statement) to a MySQL Geometry column. This function only handles Polygons and
* Multipolygons.
*
* Example:
* $definition = "MDSYS.SDO_GEOMETRY(2003,4326,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(-75.01703,41.79308,-75.02978,41.7941,-75.02735,41.772,-75.02716,41.77193,-75.02697,41.77187,-75.01354,41.79051,-75.01337,41.79061,-75.0132,41.79072,-75.00949,41.79234,-75.00946,41.79254,-75.00943,41.79274,-75.00518,41.7943,-74.9995,41.79178,-74.99365,41.79788,-74.99383,41.79798,-74.99876,41.80318,-74.9988,41.80337,-74.99883,41.80349,-75.00425,41.80479,-75.00431,41.80459,-75.01239,41.79415,-75.01245,41.79412,-75.01688,41.79345,-75.01696,41.79327,-75.01703,41.79308))";
* $sql = "INSERT INTO mytable (geom) VALUES (".OraclePolygonToMysql($definition).")";
@kehh
kehh / mysqlDataReport.sql
Last active August 29, 2015 14:20
MySQL Data Report
-- Report on table data within a database using information_schema to inspect the data
-- copied to https://gist.github.com/kehh/2ef188881002b10e4b3c
USE mecc;
SET @sql = NULL;
-- may need to be bigger depending on how many tables, columns you have and the length of data in those columns
SET @@group_concat_max_len = 500000000;
SELECT GROUP_CONCAT(
CONCAT_WS('',
'SELECT "', TABLE_NAME, '" AS tableName, "',
COLUMN_NAME , '" AS field,
@thomasfr
thomasfr / autossh.service
Last active May 9, 2024 16:59
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
{
"intrinsic_fields" : {
"idno" : "TEST-123",
"type_id" : 43
},
"preferred_labels" : [
{
"locale" : "en_US",
"forename" : "Walter",
"middlename" : "H.",
@mattratleph
mattratleph / vimdiff.md
Last active May 9, 2024 03:11 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@stefankeidel
stefankeidel / item_edit_request.json
Created October 19, 2012 11:52
CollectiveAccess providence web service example request for editing an existing item
{
"intrinsic_fields" : {
"idno" : "NEWTEST-456",
},
"remove_all_labels" : true,
"preferred_labels" : [
{
"locale" : "en_US",
"forename" : "Walter",
"middlename" : "H.",
@stefankeidel
stefankeidel / item_request.json
Created October 11, 2012 11:42
CollectiveAccess providence web service example request for new item
{
"intrinsic_fields" : {
"idno" : "TEST-123",
"type_id" : 43
},
"preferred_labels" : [
{
"locale" : "en_US",
"forename" : "Walter",
"middlename" : "H.",
@sharoonthomas
sharoonthomas / change_db_owner.sh
Created June 11, 2012 16:34 — forked from gingerlime/change_db_owner.sh
Postgresql - Changing ownership on all tables
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto