Skip to content

Instantly share code, notes, and snippets.

View CanRau's full-sized avatar
🤓
coding

Can Rau CanRau

🤓
coding
View GitHub Profile
@CanRau
CanRau / stripe-currencies.js
Created July 27, 2018 14:35 — forked from chrisdavies/stripe-currencies.js
A handy list of currency codes and descriptions for use with Stripe.
'use strict';
// The STRIPE-supported currencies, sorted by code
export const currencies = [
{
'code':'AED',
'description':'United Arab Emirates Dirham'
},
{
'code':'AFN',
@CanRau
CanRau / parseURLParameters.js
Last active March 20, 2018 20:51 — forked from pirate/parseURLParameters.js
Parse URL query parameters in ES6 (immutable version using reduce instead of map)
const getUrlParams = (search = ``) => {
const hashes = search.slice(search.indexOf(`?`) + 1).split(`&`)
return hashes.reduce((acc, hash) => {
const [key, val] = hash.split(`=`)
return {
...acc,
val: decodeURIComponent(val)
}
}, {})
}
@CanRau
CanRau / parseURLParameters.js
Created March 20, 2018 20:49 — forked from pirate/parseURLParameters.js
Parse URL query parameters in ES6
function getUrlParams(search) {
let hashes = search.slice(search.indexOf('?') + 1).split('&')
let params = {}
hashes.map(hash => {
let [key, val] = hash.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
@CanRau
CanRau / nodejs - get filesize in readable format.md
Created August 26, 2017 02:25 — forked from narainsagar/nodejs - get filesize in readable format.md
node.js - function to get file and convert the file size in humanly readable format.

node.js - get the filesize in readable format.

This will take filePath as a function parameter and reads the file via fs module and get the file and converts it's size into more humanly readable format.

function getFileSize(filePath) {
  var stats = fs.statSync(filePath);
  // console.log('stats', stats);
  var size = stats["size"];
 // convert it to humanly readable format.

How to setup gitlab without embedded nginx

Install via omnibus-package

install the normal way:

wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.2-omnibus.5.4.2.ci-1_amd64.deb & > /dev/null

sudo apt-get update
sudo apt-get upgrade
<?php
$field = $fields->get("field_name_here"); // Insert system field i.e. roles
$field->flags = Field::flagSystemOverride;
$field->flags = 0;
$field->save();
@CanRau
CanRau / fix-homebrew-npm.md
Created November 3, 2016 13:22 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@CanRau
CanRau / git-notes
Last active August 14, 2016 15:13
git notes
/**
* Git create empty branch
*/
git checkout --orphan <branchname> # branch without parents
git rm --cached -r . # clear the working directory
/**
* rename git branch locally and remotely
* @from https://gist.github.com/lttlrck/9628955
@CanRau
CanRau / TextformatterBlogImages.module
Last active April 18, 2019 10:48
Please read https://processwire.com/talk/topic/13471-better-ckeditor-image-insertion-at-least-for-me/ I'm fixing some bugs right now and am rearranging the whole thing
<?php
/**
* Add to any textarea field from field settings
* or place the following code into any template file
*
* $modules->TextformatterBlogImages->formatValue($page, new Field(), $page->body);
* where $page->body is your textarea
*
* make sure to review path to simple_html_dom.php
*
<?php namespace ProcessWire;
/**
* An Inputfield for handling relational Page inputs
*
* Delegates the actual input control to a user-defined Inputfield derived from InputfieldSelect
*
* @method PageArray getSelectablePages(Page $page)
* @method PageArray findPagesCode(Page $page)
*