Skip to content

Instantly share code, notes, and snippets.

@benjamindean
benjamindean / Code.desktop
Last active July 20, 2019 12:19
Linux desktop entry for Visual Studio Code. Goes to "/usr/share/applications/". For this to work, Code should be linked to `code` executable: https://code.visualstudio.com/Docs/setup
[Desktop Entry]
Name=Code
Exec=code %U
Terminal=false
Icon=code
Type=Application
StartupNotify=true
Categories=TextEditor;Development;Utility;
MimeType=text/plain;
@benjamindean
benjamindean / noSelection
Last active August 29, 2015 14:06
Disable element selection
@mixin noSelection {
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
@benjamindean
benjamindean / MODX switch-case by context snippet
Last active August 29, 2015 13:58
MODX switch/case by context snippet
<?php
if($modx->context->get('key') != "mgr"){
switch ($modx->context->get('key')) {
case 'web':
//Condition
break;
//More Contexts
@benjamindean
benjamindean / MODX plugn. Save Chunks and Snippets to the external files
Created April 4, 2014 08:35
MODX Revolution Plugin that saves all your Chunks and Snippets to the external files (in category folders) right in the Root directory. Save the plugin, go to "System Events", check "On Manager Cache Update", Refresh cache from Dashboard, Disable Plugin.
<?php
$chunks = $modx->getCollection('modChunk');
$snippets = $modx->getCollection('modSnippet');
foreach ($chunks as $chunk) {
$content = $chunk->getContent();
$category = "SELECT category FROM `modx_categories` WHERE id = " . $chunk->get('category') . "";
@benjamindean
benjamindean / SASS background SVG with PNG fallback
Created April 4, 2014 08:24
Creates SVG background image with PNG fallback. Example: @include('picture', 'center', 'center', 'no-repeat', 'fallback'); #{$imgFallback} - global var, folder with fallbacks.
@mixin image($name, $x, $y, $repeat, $fallback: "") {
@if $fallback == "fallback" {
background: url(#{$imgFallback}/#{$name}.png) $x $y $repeat;
background: rgba(0, 0, 0, 0) url(#{$img}/#{$name}.svg) $x $y $repeat;
}
@else {
background: url(#{$img}/#{$name}.png) $x $y $repeat;
}
}
@benjamindean
benjamindean / Absolute Position Mixin
Created April 4, 2014 08:20
Creates absolute position width SASS. Example: @include abs-pos(0 5px 0 0px);
@mixin abs-pos($coordinates: 0 0 0 0) {
$top: nth($coordinates, 1);
$right: nth($coordinates, 2);
$bottom: nth($coordinates, 3);
$left: nth($coordinates, 4);
@if not(unitless($top)) {
top: $top;
}
@if not(unitless($right)) {