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 / get-npm-package-version
Created August 15, 2018 21:51 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@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 / gist:9f70d68066983e669167
Last active October 23, 2017 04:49
Get Pinterest full size images
$json = file_get_contents('https://api.pinterest.com/v3/pidgets/boards/Globetrawter/natural-homes/pins/');
$jsonIterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($json, TRUE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($jsonIterator as $key) {
// get only url you can var_dump($key) and see what you like ;-)
if(isset($key['url']) && strpos($key['url'], '.jpg') !== false) {
@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.