Skip to content

Instantly share code, notes, and snippets.

Avatar

michele mnicole

View GitHub Profile
@mnicole
mnicole / gist:2cb3686e101d7827273eb7479ff7cc05
Created Oct 18, 2017
function to check for the position of 2 numbers that equal a certain sum
View gist:2cb3686e101d7827273eb7479ff7cc05
/**
* Function to check for the position of 2 numbers that equal a certain sum. Only one pair per array.
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
const twoSum = function(nums, target) {
let checked = {},
found;
nums.forEach((n, index) => {
View gist:f4b3e92af3dd8438d5f12a168cfa8790
{
"presets": [
"es2015", // whichever presets your projects use should match here
"stage-0",
"react"
],
"plugins": [
"transform-runtime", // for polyfills
"transform-react-remove-prop-types" // we use this to remove the propTypes
]
View gist:882f1a99cbfeabced8c1f985ab32d758
“module”: “dist-es6/index”,
“prebuild”: “rimraf dist dist-es6”, // removes the /dist-es6 folder before building
“build”: “babel components — out-dir dist-es6 — source-maps inline”, // builds everything in /components/index.js to /dist-es6
“postinstall”: “postinstall-build — only-as-dependency dist”
View gist:c04c106a3fb49d542bb366601828611d
import React, { PropTypes } from ‘react’;
const Badge = ({ text, context, className, style, ...otherProps }) => {
const classes = `${context} ${className}`;
return (
<span className={ classes } style={ style } { ...otherProps }>{ text }</span>
);
};
Badge.defaultProps = {
text: ‘’,
context: ‘default’,
@mnicole
mnicole / bookmarkletautofillformurl.md
Last active Aug 29, 2015
Bookmarklet to autofill forms (URL and TITLE of page you're on when you click the bookmarklet)
View bookmarkletautofillformurl.md

BOOKMARKLETS TO AUTO FILL FORMS

I wanted to create a bookmarklet that would find the user's URL and title of the page they were on when they clicked the bookmarklet, go to my website's create new link form, and autofill the fields with that information. While researching, I found that nothing I could find fit this description, so I cobbled the code together from a few different sources.

FIRST, create a link to the bookmarklet, which you will tell people to drag to their browser bookmark bar. This will also take in the website and decode it so it shows up as http:// in the form. Make sure you match the name of your fields in your form that you want to be autofilled.

<a href="javascript:(function(){var newURI='YOUR_URL_TO_YOUR_FORM_PAGE?NAME_OF_URL_FIELD='+encodeURIComponent(decodeURIComponent(window.location.href))+'&NAME_OF_TITLE_FIELD='+encodeURIComponent(document.title.replace('%20',' ')); window.location.href=newURI;})();">TEXT THAT THE BOOKMARKLET WILL SAY WHEN YOU DRAG IT TO YOUR BOOKMAR