Skip to content

Instantly share code, notes, and snippets.

@edtorba
edtorba / nvmuse.md
Created February 28, 2023 14:09 — forked from danpetitt/nvmuse.md
Using nvmrc on Windows

Using nvmrc on Windows

Unfortunately nvm use on Windows does not change the node version to that specified in the .nvmrc file as its not supported on nvm for Windows: coreybutler/nvm-windows#388

So the easiest solution to this is to use a simple Powershell command that performs an approximation of the command as follows: nvm use $(Get-Content .nvmrc).replace( 'v', '' );

However, thats a bit awkward and we can do a bit more so instead, we can create an 'alias' to a function that calls the command instead:

function callnvm() {
@edtorba
edtorba / readme.md
Created March 31, 2021 10:54
Get random image from unsplash.

Create a bookmarklet in your browser, give it any name that you like and place following code instead of the URL.

javascript:(function(){var size=prompt("Please enter image size");size&&window.open(`https://source.unsplash.com/random/${size}`,"_blank").focus();})();
@edtorba
edtorba / regex cheatsheet.md
Last active March 10, 2021 13:50
List of handy regex patterns

Find duplicate query parameters

((foo|bar)=).*\1

----
foo=bar&bar=foo [ok]
foo=bar&bar=foo&foo=woo [not  ok]
bar=foo&bar=foo [not ok]
foo=bar&bar=foo&woo=xoo [ok]

Caching Options

  • Clear on Index Update: Indicates that the cache should be cleared when the index is updated – if your code depends on an index, selecting this will help prevent any race conditions occurring between HTML caching and index update operations.
  • Vary By Data: Generate a cached version per data source
  • Vary By Device: Generate a cached version per device
  • Vary By Login: Generate a cached version for authenticated users and one for unauthenticated users
  • Vary By Parm: Generate a cached version per rendering parameter
  • Vary By Query String: Generate a cached version for each unique combination of querystring parameter
  • Vary by User: Generate a cached version per authenticated user

Cache

@edtorba
edtorba / converter.php
Last active December 8, 2021 16:02
Excel "ifs" statement converter to nested "if" statement for laravelexcel
<?php
function convertIfs($formula)
{
$formula = substr($formula, 5); // Removing =IFS(
$formula = substr($formula, 0, -1); // Removing ) from the end of the string
$exploded = explode(',', $formula);
$composed_if = '';
for($t = count($exploded) - 1, $i = $t; $i > -1; $i--)
{
@edtorba
edtorba / DragTransform
Created March 17, 2016 15:15 — forked from fta2012/DragTransform
Slightly modified compiled coffeescript from this codepen: http://codepen.io/fta/pen/ifnqH. Paste into console on a page that has jQuery to load the two dependent libraries (jquery-ui and numericjs). Then call makeTransformable('#selector-name') to make that element WYSIWYG editable. Use inspector to get the CSS for the transforms.
var selector = 'img' // Replace this with the selector for the element you want to make transformable
jQuery.getScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', function() {
jQuery.getScript('//cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js', function() {
(function() {
var $, applyTransform, getTransform, makeTransformable;
$ = jQuery;