Skip to content

Instantly share code, notes, and snippets.

View seanblonien's full-sized avatar
💭
🐬

Sean Blonien seanblonien

💭
🐬
View GitHub Profile
@seanblonien
seanblonien / practice-problems.md
Last active November 14, 2023 03:35
JavaScript Practice Problems

Practice Problems

Practice problems oriented towards dealing with functions, arrays, loops, and conditions.

💻 Use PlayCode to develop online and run the code instantly

Problem 1

You are working for a non profit that is building their own website which lets users login using their email address. All users with an account will have emails that end in .org, and contain @ symbol in the email.

@seanblonien
seanblonien / cloc.ps1
Last active October 12, 2021 04:39
CLOC Count Lines of Code Example Usage for Node, Typescript, React, NextJS, Vercel, Lerna Monorepo
# Windows *REQUIRES* downloading Perl to run, which you can get using `choco install strawberryperl`.
npx cloc --fullpath --match-f=".tsx|.ts|.js" --not-match-f="node_modules|lib|package-lock.json|/.next|/.vercel" .
@seanblonien
seanblonien / customJSXAttributes.d.ts
Last active February 16, 2021 04:32
Adding Custom Attributes for JSX/HTML in TypeScript with React
// Hate seeing this VSCode/TypeScript error with custom attributes?
// Type '{ name: string; value: string; }' is not assignable to type 'DetailedHTMLProps<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>'.
// Property 'value' does not exist on type 'DetailedHTMLProps<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>'
//
// Here's a fix to that for all HTML elements in JSX/React.
declare module 'react' {
// Add a custom attribute to *all* HTML elements parsed by TypeScript.
// This is required when the element you want to add the attribute to doesn't
// have it's own attributes type definition (which is most of them).
@seanblonien
seanblonien / DisableRightClickOnImage.html
Created March 15, 2019 05:22
Disable Right Click/Context Menu On Image/Photo
<!-- Past in HTML of page that you want right click of image disabled -->
<script src="http://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=" crossorigin="anonymous"></script>
<script type="text/javascript">
$('img').bind('contextmenu', function(e) {
return false;
});
</script>
@seanblonien
seanblonien / .htaccess
Created March 7, 2019 22:35
.htaccess add www and redirect http to https for Apache Web Server
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@seanblonien
seanblonien / CalculateSelection.bas
Last active August 10, 2018 20:44
Excel VBA Calculate/Update/Evaluate Selection/Selected Cells/Selected Range
' These macros are meant to be used with Manual Calculation to just
' calculate the selected cells. The verbose macro shows the
' progress of the calculation by showing what current cell is
' calculating out of the total number of cells. The verbose macro also
' displays how long the macro took to finish.
Option Explicit
' ----------------------------------------------------------------
' Procedure Name: CalculateSelection
@seanblonien
seanblonien / SheetExists.bas
Created August 10, 2018 16:08
Excel VBA Check/Determine if Sheet/Tab/Worksheet Exists
' ----------------------------------------------------------------
' Procedure Name: SheetExists
' Purpose: Determine whether or not a sheet/tab exists
' Procedure Kind: Function
' Procedure Access: Public
' Return Type: Boolean
' Author: sb172a
' Date: 8/10/2018
' ----------------------------------------------------------------
Function SheetExists(SheetName As String, Optional GivenWorkbook As Workbook) As Boolean
@seanblonien
seanblonien / AlphaNumericOnly.bas
Created August 10, 2018 15:39
Excel VBA Remove Special Characters and Spaces/Alpha Numeric Only/Letters Numbers Only
' ----------------------------------------------------------------
' Procedure Name: AlphaNumericOnly
' Purpose: Removes non-alpha numeric characters from the given string
' Procedure Kind: Function
' Procedure Access: Public
' Parameter SourceString (String): the string to remove non alpha numeric values from
' Return Type: String
' Author: sb172a
' Date: 8/9/2018
' ----------------------------------------------------------------
@seanblonien
seanblonien / TabName.bas
Created July 25, 2018 16:24
Excel VBA Get Tab/Sheet/Worksheet Name for calling Function/Formula
' ----------------------------------------------------------------
' Procedure Name: TabName
' Purpose: Returns the current sheet/tab name
' Procedure Kind: Function
' Procedure Access: Public
' Author: sb172a
' Date: 7/3/2018
' ----------------------------------------------------------------
Function TabName()
TabName = Application.Caller.Worksheet.Name
@seanblonien
seanblonien / TextToNumber.bas
Last active July 12, 2018 15:51
Excel VBA Convert Text/Range/Selection/Column To Numbers/Number Values
' When comparing these methods, a few tests were done to test their efficiency...
' Test 1: one column, 100,000 total text numbers in the column
' SelectionToNumberInPlace Time: 2.122 seconds
' SelectionToNumberColumn Time: 4.124 seconds
' Test 2: one column, 1,048,576 total text numbers in the column
' SelectionToNumberInPlace Time: 18.1218 seconds
' SelectionToNumberColumn Time: 15.1213 seconds
' Test 3: two columns, 2,097,152 total text numbers in the columns
' SelectionToNumberInPlace Time: 24.1224 seconds
' SelectionToNumberColumn Time: 31.1231 seconds