Skip to content

Instantly share code, notes, and snippets.

@JeffTomlinson
JeffTomlinson / ExamplePlugin.php
Last active January 18, 2021 20:23
Drupal 8 Logger Dependency Injection
<?php
namespace Drupal\example\Plugin\ExamplePlugin;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Logger\LoggerChannel;
/**
* Example plugin.
@drbild
drbild / generate-persistent-net-rules.sh
Last active February 9, 2024 21:12
Generate udev rules for persistent interface names by bus path, not mac address
#!/bin/sh -e
# Copyright (C) 2006 Marco d'Itri <md@Linux.IT>
# Copyright (C) 2007 Kay Sievers <kay.sievers@vrfy.org>
# Copyright (C) 2018 David R. Bild <david.bild@xaptum.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
@jeffhuangtw
jeffhuangtw / JSON2CSV.js
Created January 3, 2018 08:17
Convert json object to csv download link javascript
// Sample: download json as excel file (BOM + utf-16le encoding)
// reference:
// https://gist.github.com/maciejjankowski/2db91642fb9eaa771111f2c0538e4560
//
<script>
function JSON2CSV(objArray) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var str = '';
var line = '';
// header
@miglen
miglen / linux-networking-tools.md
Last active April 23, 2024 11:39
Linux networking tools

List of Linux networking tools

netstat (ss)

Displays contents of /proc/net files. It works with the Linux Network Subsystem, it will tell you what the status of ports are ie. open, closed, waiting, masquerade connections. It will also display various other things. It has many different options. Netstat (Network Statistic) command display connection info, routing table information etc. To displays routing table information use option as -r.

Sample output:

Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)    
tcp4 0 0 127.0.0.1.62132 127.0.0.1.http ESTABLISHED
@JeffTomlinson
JeffTomlinson / MyService.php
Last active July 22, 2023 16:28
Drupal 8 Configuration Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Config\ConfigFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services
@JeffTomlinson
JeffTomlinson / MyService.php
Last active December 22, 2021 07:49
Drupal 8 Logger Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Logger\LoggerChannelFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services
@kevinelliott
kevinelliott / osx-10.11-setup.md
Last active April 10, 2022 15:47
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@paulbarbu
paulbarbu / instructions.txt
Created January 11, 2012 21:13
Pacman pkg back-up and recovery
Backing up and retrieving a list of installed packages
It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation.
First, backup the current list of non-local packages:
$ comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > pkglist
Store the pkglist on a USB key or other convenient medium or gist.github.com or evernote or dropbox.
Copy the pkglist file to the new installation, and navigate to the directory containing it.
Issue the following command to install from the backup list:
# pacman -S $(< pkglist)
In the case you have a list which was not generated like mentioned above, there may be foreign packages in it (i.e. packages not belonging to any repos you have configured, or packages from the AUR).
In such a case, you may still want to install all available packages from that list: