Skip to content

Instantly share code, notes, and snippets.

View prograhammer's full-sized avatar

David Graham prograhammer

View GitHub Profile
@prograhammer
prograhammer / applyRegexToAllFilesInDirectory
Created January 22, 2021 08:45 — forked from crubier/applyRegexToAllFilesInDirectory
Apply Regex to all files in directory, using node js
var fs = require('fs');
function readFiles(dirname, onFileContent, onError) {
fs.readdir(dirname, function(err, filenames) {
if (err) {
onError(err);
return;
}
filenames.forEach(function(filename) {
fs.readFile(dirname + filename, 'utf-8', function(err, content) {

Using the classnames.bind method

Many people who work with React are familiar with the excellent classnames library. If you aren't familiar, it provides a simple function for gluing classnames together. In web programming in general, there are many times that we need to add or remove multiple classes based on conditional logic. The classnames library makes this easy.

More and more developers are embracing CSS Next and the power of CSS modules. However, when you add CSS modules to your react components, working with classnames gets more difficult. Typically, CSS modules is implemented with class name mangling. Transforming human readable class name strings into unique identifiers helps ensure that every class name in your app is unique.

This means that you can write your component CSS in isolation without worrying about the dreaded class name collisions that have plagued CSS

@prograhammer
prograhammer / .bashrc
Created September 15, 2019 06:52 — forked from mathiasverraes/.bashrc
Git shortcuts
#! /bin/sh
alias gs="git status"
alias gc="git commit"
alias gr="git checkout"
alias ga="git add"
alias gl="git lola"
@prograhammer
prograhammer / Remove all git tags
Last active September 14, 2019 06:43 — forked from okunishinishi/Remove all git tags
Delete all git remote tags
#Delete local tags.
git tag -d $(git tag -l)
#Fetch remote tags.
git fetch
#Delete remote tags.
git push origin --delete $(git tag -l) # Pushing once should be faster than multiple times
#Delete local tags.
git tag -d $(git tag -l)
@prograhammer
prograhammer / README.md
Created June 19, 2019 03:08 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@prograhammer
prograhammer / pr.md
Created October 10, 2018 16:46 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@prograhammer
prograhammer / babel-polyfill.md
Last active August 16, 2018 05:19
Features Babel does and doesn't transpile

Features that need to be compiled

  • Arrow functions
  • Async functions
  • Async generator functions
  • Block scoping
  • Block scoped functions
  • Classes
  • Class properties
  • Computed property names
  • Constants
@prograhammer
prograhammer / regex.md
Last active July 21, 2018 21:57
Regex by example
@prograhammer
prograhammer / index.html
Created July 18, 2018 19:20 — forked from jonnyreeves/index.html
JavaScript Class Structure using requireJS. The following code shows you how to create a Class definition in one JavaScript file and then import it for use in another; coming from an ActionScript 3 background this (and some of JavaScript specific traits)
<!DOCTYPE html>
<html>
<head>
<script data-main="usage" src="http://requirejs.org/docs/release/1.0.8/comments/require.js"></script>
</head>
<body>
<p>Check your JavaScript console for output!</p>
</body>
</head>
@prograhammer
prograhammer / curl.md
Created February 28, 2018 06:19 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.