Skip to content

Instantly share code, notes, and snippets.

View egil's full-sized avatar

Egil Hansen egil

View GitHub Profile
@egil
egil / dotnet-format-action.yml
Created July 27, 2020 08:42 — forked from rickyah/dotnet-format-action.yml
Runs dotnet-format on every PR and create a commit that fixes the formatting if it doesn't comply with your code convention
name: Format check on pull request
on: pull_request
jobs:
dotnet-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/[email protected]
with:
fetch-depth: 0
@egil
egil / AllCombinations.cs
Created October 7, 2019 21:55
A C# IList extension method that returns all combinations of the content of the list. See related question on StackOverflow: https://stackoverflow.com/questions/7802822/all-possible-combinations-of-a-list-of-values/40417765#40417765
using System;
using System.Collections.Generic;
public static class ListExtensions
{
public static IEnumerable<List<TInput>> AllCombinations<TInput>(this IList<TInput> list)
=> list.AllCombinations(() => new List<TInput>(), (list, item) => list.Add(item));
public static IEnumerable<TCombinationContainer> AllCombinations<TInput, TCombinationContainer>(
this IList<TInput> list,
@egil
egil / drupal-webform-nationalities.txt
Created October 26, 2012 11:40
A list of nationalities formatted for use with Drupals Webform module
Afghan|Afghan
Albanian|Albanian
Algerian|Algerian
American|American
Andorran|Andorran
Angolan|Angolan
Antiguans|Antiguans
Argentinean|Argentinean
Armenian|Armenian
Australian|Australian
@egil
egil / gist:1621550
Created January 16, 2012 16:07
Drupal: Get contextual links on nodes
// In template.php:
function THEME_menu_local_tasks($variables) {
// Add contextual links js and css library
drupal_add_library('contextual', 'contextual-links');
$output = '';
if (!empty($variables['primary'])) {
$variables['primary']['#prefix'] = '<div class="contextual-links-wrapper"><ul class="contextual-links">';
$variables['primary']['#suffix'] = '</ul></div>';
@egil
egil / gist:1616481
Created January 15, 2012 17:14
Drupal: Removes all stylesheets except those added by the theme. Should be added to your template.php file. More info can be found here: http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_css_alter/7
function THEME_css_alter(&$css) {
foreach ($css as $key => $value) {
if ($value['group'] != CSS_THEME) {
$exclude[$key] = FALSE;
}
}
$css = array_diff_key($css, $exclude);
}