Skip to content

Instantly share code, notes, and snippets.

View ricokareem's full-sized avatar
:octocat:

Rico Rodriquez Collins ricokareem

:octocat:
View GitHub Profile
@ricokareem
ricokareem / gist:e05b6d5d6f27856336bde7378a6ce94f
Created April 29, 2021 15:57 — forked from clintel/gist:1155906
Fenced code in bullet lists with GitHub-flavoured MarkDown??

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@ricokareem
ricokareem / HighlightedResults.jsx
Created January 26, 2021 19:11
[React] Highlight search string matches in results without dangerouslySetInnerHTML
// Highlight search string matches in results
const HighlightedResults = (): JSX.Element | null => {
if (inputValue) {
const match = item.name.match(new RegExp(inputValue, 'i'))
const MatchEl = (): ReactElement | null => {
if (match && match.length) {
return <strong>{match[0]}</strong>
} else {
return null
}
@ricokareem
ricokareem / react-forwardref-simple-example.js
Created December 1, 2020 23:24 — forked from jamesreggio/react-forwardref-simple-example.js
Simple example usage of React.forwardRef()
// EmailInput wraps an HTML `input` and adds some app-specific styling.
const EmailInput = React.forwardRef((props, ref) => (
<input ref={ref} {...props} type="email" className="AppEmailInput" />
));
class App extends Component {
emailRef = React.createRef();
render() {
return (
@ricokareem
ricokareem / README.md
Created November 10, 2020 01:42 — forked from remarkablemark/README.md
How to mock `window.location.reload` in Jest and jsdom: https://remarkablemark.org/blog/2018/11/17/mock-window-location/
@ricokareem
ricokareem / cookieUtil.js
Last active July 8, 2020 21:21
basic cookie functions
const getCookie = (name) => {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for(let i=0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.

Mac

git config --global core.excludesfile ~/.gitignore

Windows

git config --global core.excludesfile %USERPROFILE%\.gitignore
hello world!
<script>alert("this should be escaped")</script>

`

#!/bin/bash
if [[ "$1" != "" ]]; then
BASEBRANCH="$1"
else
BASEBRANCH="development"
fi
git remote prune origin
echo "Base Branch: ${BASEBRANCH}"
@ricokareem
ricokareem / simple quicksort algo
Last active July 15, 2017 18:49
JS Bin[simple quicksort algo]// source http://jsbin.com/wenayu
function quickSort(data) {
if (data.length < 1) {
return [];
}
var left = [];
var right = [];
var pivot = data[0];
for (var i=1; i<data.length; i++) {
@ricokareem
ricokareem / binary search algo
Last active July 15, 2017 18:48
JS Bin[binary search algo]// source http://jsbin.com/koluho
function binarySearch(data, value) {
while (true) {
var mid = parseInt(data.length/2);
if (value === data[mid]) {
return data[mid];
} else if (value > data[mid]) {
data = data.slice(mid);
} else if (value < data[mid]) {
data = data.slice(0, mid);