Skip to content

Instantly share code, notes, and snippets.

karltaylor / findAndReplace.js
Last active Mar 24, 2020
Module to find and replace parts of a file.
View findAndReplace.js
const fs = require('fs');
const signale = require('signale');
module.exports = (filePath, regex, replacement) =>
new Promise((yep, nope) => {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.log(err); // eslint-disable-line
View EditUserProfile.js
// @flow
import React, { useState } from 'react';
import { KeyboardAvoidingView, ScrollView, Text, View } from 'react-native';
import { Header } from '../../components/Header';
import { Button } from '../../components/Button';
import { ProfileImage } from '../../components/ProfileImage';
import PostInput from '../../components/PostInput';
import PostBody from '../../components/PostBody';
karltaylor / main.code-snippets
Created Jun 21, 2018
Visual Studio Code Snippets
View main.code-snippets
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
karltaylor / split.js
Last active Jul 7, 2017
Split string but keep delimiter
View split.js
function split(string) {
return string.match(/\w+(?:\s\w+)*\W?/g)
console.log(split("string one, string two, thing three, four four."))
// ["string one,", "string two,", "thing three,", "four four."]
convert -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% part-1.jpg result.jpg
karltaylor / handle-input-change.js
Last active Aug 2, 2018
Handle Input Change React
View handle-input-change.js
handleChange = e => {
const {name, value} = e.currentTarget
[name]: value
// Make sure you've set a 'name' attribute on the input.
karltaylor / social-network-metadeta.pug
Last active Feb 8, 2022
Meta data for Facebook OpenGraph and Twitter cards in .pug format.
View social-network-metadeta.pug
//- Facebook Open Graph Meta Data
meta(property="og:url" content="")
meta(property="og:type" content="")
meta(property="og:title" content="")
meta(property="og:description" content="")
meta(property="og:image" content="")
//- Twitter Meta Data
meta(name="twitter:card" content="summary_large_image")
meta(name="twitter:site" content="")
karltaylor / ffmpeg-compress-mp4
Last active Jul 26, 2021
Compress MP4 for online content.
View ffmpeg-compress-mp4
ffmpeg -i input.mp4 -codec:v libx264 -preset slow -b:v 1000k -maxrate 1500k -bufsize 1500k -vf scale=1080:-1 -threads 0 -codec:a libfdk_aac -b:a 128k output.mp4
karltaylor / UIBorderedLabel.swift
Created Dec 1, 2016 — forked from karloscarweber/UIBorderedLabel.swift
UILabel subclass that makes setting padding really easy.
View UIBorderedLabel.swift
// UIBorderedLabel.swift
// standToMake
// Created by Karl Oscar Weber on 9/13/14.
// Copyright (c) 2014 Karl Oscar Weber. All rights reserved.
// Thanks to:
import UIKit
karltaylor /
Created Aug 12, 2016
Convert image to different format.
for i in *.png; do convert -verbose $i ${i%%.png}.jpg; done && open .