Skip to content

Instantly share code, notes, and snippets.

@vidhav
vidhav / leaflet-med-norske-kart.html
Created October 13, 2016 07:15
Eksempel på oppsett av Leaflet med kart fra Kartverket.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Leaflet med norske kart</title>
<link href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" rel="stylesheet" />
</head>
<body>
<div id="map" style="height: 400px; width: 600px;"></div>
<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script>

Test

The Ninja Made a Movement.

  • Lorem.
  • Ipsum.
  • Dolor.

Foo bar!

@vidhav
vidhav / minify.py
Created December 23, 2015 09:32
Use jsmin() to minify a js-file or a folder containing js-files.
import os;
import sys;
from jsmin import jsmin;
if len(sys.argv) < 2:
print '- Requires .js-file or directory containing js.files';
exit();
input = os.path.abspath(sys.argv[1]);
name = os.path.splitext(input)[0] + '.min.js';
@vidhav
vidhav / youtube.videos.php
Created November 6, 2015 13:50
How to get videos by ids in Google API 3
<?php
$ids = array(
'spepfQLXrm4',
'OmcJbaHw2C8',
'D0-tHS7GQxM',
);
$key = '<GoogleApiKey>';
$parts = array(
'contentDetails',
'snippet',
@vidhav
vidhav / collections.imageplus.js
Last active April 12, 2024 11:43
Custom MODX Collections renderer for Image+
Collections.renderer.imageplus = function(value, metaData, record, rowIndex, colIndex, store) {
if (value != '' && value != null) {
var data = Ext.decode(value);
var url = MODx.config.connectors_url + 'system/phpthumb.php?imageplus=1';
var params = {};
params.src = MODx.config['collections.renderer_image_path'] + data.sourceImg.src;
params.w = 100;
if (data.sourceImg.src.indexOf('.png') !== -1) {
params.f = 'png';
@vidhav
vidhav / vertical-align.css
Created October 27, 2015 21:42
CSS Vertical Align
.parent-element {
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}
@vidhav
vidhav / grid.css
Last active October 23, 2015 10:50
Modified Bootstrap Grid
@-ms-viewport {
width: device-width;
}
@media (max-width: 767px) {
.align-mobile-left {
text-align: left;
}
.align-mobile-center {
text-align: center;
}
@vidhav
vidhav / imagefix.sh
Created August 26, 2015 13:31
Fix image size and dpi recursively
#!/bin/bash
find . -type f -name '*.jpg' -print0 | while IFS= read -r -d '' file; do
report="$(date "+%Y-%m-%d %H:%M:%S")"
report+=" ($file)"
str="$(identify -format "%w;%h;%x;%y" "$file")"
arr=(${str//;/ })
w=${arr[0]:-0}
@vidhav
vidhav / snippet.containing.php
Created May 21, 2015 07:12
MODX Output Modifier checks if $input contains a string defined in the $options value.
<?php
/**
* Returns a value if input contains string
* [[*link_attributes:containing=`blank=New Window&self=This window`]]
*/
parse_str($options, $cases);
$output = 'no-match';
foreach ($cases as $needle => $value) {
if (strpos($input, $needle) !== false) {
<?php
if ($modx->event->name = 'OnLoadWebDocument') {
$modx->setPlaceholder('get', '<pre>'.print_r($_GET, true).'</pre>');
$modx->toPlaceholders($_GET, 'get');
}
return;