Skip to content

Instantly share code, notes, and snippets.

View cesarfigueroa's full-sized avatar

Cesar Figueroa cesarfigueroa

View GitHub Profile
@cesarfigueroa
cesarfigueroa / paste.js
Created September 25, 2014 23:48
Paste onto a [contenteditable] element as plain text
document.querySelector('[contenteditable]').addEventListener('paste', function (event) {
event.preventDefault();
document.execCommand('inserttext', false, event.clipboardData.getData('text/plain'));
});
@cesarfigueroa
cesarfigueroa / cors.sh
Created January 22, 2016 17:55
Making a CORS request with cURL
curl --verbose --silent --header 'Origin: [TDL_DOMAIN]' [RESOURCE_URL] 1> /dev/null

Keybase proof

I hereby claim:

  • I am cesarfigueroa on github.
  • I am cesarfigueroa (https://keybase.io/cesarfigueroa) on keybase.
  • I have a public key ASCUcTWHUmZ18gMbb56IHd8EtFblmoHUGNBR3uJXOXbdLQo

To claim this, I am signing this object:

@cesarfigueroa
cesarfigueroa / flow-component-without-props.js
Created September 23, 2018 19:34
Component Without Props in Flow
// @flow
import * as React from 'react';
type ProplessComponent = React.ComponentType<{||}>
const component: ProplessComponent = () => <p>Hello World</p>
React.createElement(component, Object.freeze({}))
React.createElement(component, Object.freeze({ a: 1 })) // Error!
base64 -d <<< "$(pbpaste)" > file.jpg
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
function moveItem(list, from, to) {
return list.delete(from).insert(to, list.get(from));
}
@cesarfigueroa
cesarfigueroa / ordinals.rb
Last active September 7, 2017 03:29
Ordinal Indicators in Ruby
class Fixnum
def with_ordinals
if (11..13).include?(self.abs % 100)
'th'
else
case self.abs % 10
when 1 then 'st'
when 2 then 'nd'
when 3 then 'rd'
else 'th'
git push staging $(git rev-parse --abbrev-ref HEAD):master
const WHITESPACE_PATTERN = /^[ \t]*(?=\S)/gm;
export function stripIndent(strings, ...expressions) {
const resultString = strings.reduce((accumulator, part, i) => {
return accumulator + expressions[i - 1] + part;
});
const indents = Math.min(
...resultString.match(WHITESPACE_PATTERN).map(whitespace => whitespace.length)
);