Skip to content

Instantly share code, notes, and snippets.

@marcorivm
marcorivm / copyParams.js
Created November 10, 2021 14:44
Copy query parameters into a form
// Parse an url and get query parameters
const getParams = function (url) {
const params = {}
const parser = document.createElement('a')
parser.href = url
const query = parser.search.substring(1)
const vars = query.split('&')
for (let i = 0; i < vars.length; i++) {
let pair = vars[i].split('=')
params[pair[0]] = decodeURIComponent(pair[1])
@marcorivm
marcorivm / .env
Created July 20, 2021 13:46
Add Facebook Pixel to Sharetribe Flex project
REACT_APP_FB_PIXEL_ID=
#!/bin/bash
# You don't need some other library to upload to S3 -- shell works perfectly fine
# Based on a modified script from here https://gist.github.com/chrismdp/6c6b6c825b07f680e710 and here http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
@marcorivm
marcorivm / s3.sh
Created March 4, 2020 17:55 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@marcorivm
marcorivm / YNAB.js
Last active April 23, 2019 20:43
Get Selected ynab items to json
function selectedItemsToCSV() {
let items = [...document.querySelectorAll('.ynab-grid-body-row.is-checked')].map(item => {
return {
Date: item.querySelector('.ynab-grid-cell-date').innerText.trim(),
Payee: item.querySelector('.ynab-grid-cell-payeeName').innerText.trim(),
// subCategoryName: item.querySelector('.ynab-grid-cell-subCategoryName').innerText.trim(),
Memo: item.querySelector('.ynab-grid-cell-memo').innerText.trim(),
Inflow: (item.querySelector('.ynab-grid-cell-outflow').innerText.trim()).replace("$", "").replace(",", ""),
Outflow: (item.querySelector('.ynab-grid-cell-inflow').innerText.trim()).replace("$", "").replace(",", "")
}
@marcorivm
marcorivm / install_php.sh
Created December 2, 2018 21:46
Install php and composer on ubuntu 16.04 (for coder.com)
cd ~
apt-get install -y software-properties-common python-software-properties &&
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php &&
apt-get update &&
apt-get install -y php7.2 php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-intl php7.2-mysql php7.2-xml php7.2-zip php7.2-bcmath
curl -sS https://getcomposer.org/installer -o composer-setup.php
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
@marcorivm
marcorivm / App_Http_Middleware_ConvertToCamelCase.php
Created June 27, 2018 02:37
Based on https://github.com/flugger/laravel-responder these middlewares can be included with any laravel controller to convert response values from camelCase which is usually the standard on js clients and snake_case preferred on PHP
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\JsonResponse;
/**
* A middleware class responsible for converting incoming parameter keys to camel case.
*
* @package flugger/laravel-responder
* @author Alexander Tømmerås <flugged@gmail.com>
@marcorivm
marcorivm / App_Http_Serializers_SirenSerializer.php
Created June 24, 2018 23:59
Siren Serializer for https://fractal.thephpleague.com/ needed to change a few things with the Scope to allow for the pagination, this is a WIP but I decided to go for pure JSON Shema so I'm not working onthis implementatio anymore
<?php namespace App\Http\Serializers;
use League\Fractal\Serializer\ArraySerializer;
use League\Fractal\Pagination\PaginatorInterface;
class SirenSerializer extends ArraySerializer
{
protected $baseUrl;
copy(jQuery('.list-card-details').map(function(key, item) {
jQuery(item).children('.list-card-title').children('span').remove()
var title = jQuery(item).children('.list-card-title').text();
var points = jQuery(item).find('.badges .badge-points:not(.consumed)').text()
title = "[" + points + "] " + title;
return title;
}).toArray().join('\n'));
@marcorivm
marcorivm / AppServiceProvider.php
Created August 28, 2016 05:42 — forked from snipe/AppServiceProvider.php
Validate email array in Laravel 5.2 wth custom validator
<?php
/**
* This service provider handles a few custom validation rules.
*
* PHP version 5.5.9
* @package Snipe-IT
* @version v3.0
*/
namespace App\Providers;