Skip to content

Instantly share code, notes, and snippets.

{
"editor.tabSize": 2,
"editor.fontSize": 15,
"window.zoomLevel": 0,
"editor.codeLens": true,
"editor.cursorStyle": "underline",
"editor.lineNumbers": "relative",
"workbench.welcome.enabled": false,
"workbench.colorTheme": "Dracula",
"workbench.iconTheme": "vscode-icons",
{
"Badge Text" : "",
"Ansi 5 Color" : {
"Green Component" : 0.4745098039215686,
"Blue Component" : 0.7764705882352941,
"Red Component" : 1
},
"Working Directory" : "\/Users\/scienceonlineed",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
@heyMP
heyMP / gist:297a2a252de21ece4d9827d9a08aecf4
Last active May 31, 2018 18:14
Check Disk Usage in Gigabytes
# linux
df -bg
@heyMP
heyMP / index.js
Created February 12, 2018 20:57
Attempt at replacing markdown tags to custom element tags. TLDR; Markdown hates custom elements
const fs = require('fs');
const path = require('path');
const marked = require('marked');
const cheerio = require('cheerio');
var nodePandoc = require('node-pandoc');
const location = './';
/**
* Parse an outline to get the structure of a book
* @todo This just supports gitbook right now, add other parsers
@heyMP
heyMP / script.js
Created September 13, 2017 17:02
Get a list of unique values
var verbs = result.map(i => i.statement.verb.id);
var uniqueVerbs = verbs.filter((v, i, a) => a.indexOf(v) === i);
@heyMP
heyMP / index.php
Created September 12, 2017 19:43
Array Types
<?php
// iterative array
$array = array('apple', 'banana', 'pear');
// or
$array = array(0 => 'apple', 1 => 'banana', 2 => 'pear');
// associative array
$array = array('fruit' => 'apple', 'veggie' => 'cucumber');
$array = array(
@heyMP
heyMP / index.js
Last active September 12, 2017 18:43
Loops
var people = ['Mike', 'Carly', 'Chuck'];
// old way
people.foreach(function(index, person) {
people[index] = 'Developer: ' + person;
});
// new way :)
var newPeople = people.map(function(person) {
return 'Developer: ' + person;
@heyMP
heyMP / index.js
Last active September 12, 2017 17:26
If's
var wide = true;
if (wide) {
return 'you are really big';
}
else {
return 'you are very small';
}
@heyMP
heyMP / template.php
Last active April 9, 2017 20:18
Getting an image url from a taxonomy term using field_view_field. This requires the image_url_formatter module.
<?php
function theme_form_element_label($variables) {
$_term = taxonomy_term_load($element['#return_value']);
$_image = field_view_field('taxonomy_term', $_term, 'field_camo_image', array('type'=>'image_url'));
// if the term has an image then we are going to use it
if ($_image) {
$radioimage_attrs['image'] = render($_image[0]);
}
}