Skip to content

Instantly share code, notes, and snippets.

@gregmercer
gregmercer / D8 - Services with Dependency Injection
Last active April 8, 2022 08:18
D8 - Services with Dependency Injection Example
D8 - Services with Dependency Injection
...
lightning-8/modules/custom/basic/basic.services.yml
services:
basic.basic_hero_articles:
class: Drupal\basic\BasicArticleService
@gregmercer
gregmercer / D8 - Services
Created January 16, 2019 16:48
D8 - Services Example
D8 - Services
...
lightning-8/modules/custom/basic/basic.services.yml
services:
basic.basic_hero_articles:
class: Drupal\basic\BasicArticleService
@gregmercer
gregmercer / D8 - Twig Templates Attach Library
Created January 15, 2019 23:24
D8 - Twig Templates Attach Library
Twig Templates
Attach Library
...
lightning-8/modules/custom/basic/css
animate.css
...
@gregmercer
gregmercer / D8 - Plugin Block
Created January 15, 2019 22:58
D8 - Plugin Annotation Block Example
Plugins / Annotation / Blocks
...
lightning-8/modules/custom/basic/src/Plugin/Block/BasicHeroBlock.php
<?php
namespace Drupal\basic\Plugin\Block;
@gregmercer
gregmercer / D8 - Basic Module Controller Routes
Created January 15, 2019 22:25
D8 - Basic Module / Controller / Routes Example
Basic Module
Controller / Routes
...
lightning-8/modules/custom/basic/basic.info.yml
name: "Basic"
description: "A Basic Module"
@gregmercer
gregmercer / slack-go-private
Created November 11, 2018 17:26
Slack node js code to take a user to a private channel
function sendGoPrivateMessage(channel, user_id, firstName) {
let teamId = 'T########';
let post =
{
channel: channel,
user: user_id,
text: 'Hi ' + firstName + ', I can help you book your room. Let\'s work on your new reservation in private.' ,
attachments:
@gregmercer
gregmercer / gist:b1f1a364f433225c7502f781c9f6400d
Last active April 19, 2018 14:19
curl POST using php - with json data
<?php
$endpoint = "<the endpoint url for the post>";
function doPost($endpoint) {
$items = array(
'postitem1' => 'abc',
'postitem2' => 'def',
);
@gregmercer
gregmercer / phpbash.sh
Last active April 19, 2018 14:10
Running php from bash
#!/usr/bin/env bash
PHP=`which php`
$PHP example.php
@gregmercer
gregmercer / DroidNeedUpdate.cs
Created July 5, 2017 15:58
Xamarin Android - Checks if App needs to be updated, and if so takes the user to the Google Play Store.
private void GetUpdate()
{
try
{
StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + PackageName)));
}
catch (ActivityNotFoundException e)
{
// Default to the the actual web page in case google play store app is not installed
StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=" + PackageName)));
find . -name "*.cs" | while read line; do expand -t 4 $line > $line.new; mv $line.new $line; done