Skip to content

Instantly share code, notes, and snippets.

View madhanhere's full-sized avatar
💭
Making something great!

madhankumar madhanhere

💭
Making something great!
View GitHub Profile
import {Directive, Component, Input, ViewContainerRef, TemplateRef, AfterViewInit} from '@angular/core';
@Directive({selector: '[inView]'})
export class InView implements AfterViewInit {
alreadyRendered: boolean; // cheking if visible already
constructor(
private vcRef: ViewContainerRef,
private tplRef: TemplateRef<any>
) {}
@jbutko
jbutko / handle-file-download-react-axios.js
Last active January 31, 2024 04:48
React, JS, Axios: Download blob file (PDF...)
import axios, { AxiosResponse } from 'axios';
import { get } from 'lodash-es';
const rest = axios.create({
baseURL: 'some base URL goes here',
});
// this one send file as Blob type
const getPdf = () => (
rest.get(`/get-pdf`, {
@fr-ser
fr-ser / debounce.ts
Last active July 15, 2023 15:12
Typed debounce function wtih TypeScript
export function debounce<F extends Function>(func:F, wait:number):F {
let timeoutID:number;
if (!Number.isInteger(wait)) {
console.warn("Called debounce without a valid number")
wait = 300;
}
// conversion through any necessary as it wont satisfy criteria otherwise
return <any>function(this:any, ...args: any[]) {
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@joe-dempsey
joe-dempsey / modal in shopify order conf page
Created November 24, 2017 09:10
Modal/popup in Shopify order confirmation.
{% assign warranty = false %}
{% for line in line_items %}
{% if line.sku == 'BB-WARRANTY' %}
{% assign warranty = true %}
{% endif %}
{% endfor %}
@primaryobjects
primaryobjects / react-confirm.js
Created November 1, 2017 19:03
A simple example of a confirm alert dialog in ReactJs / React.
<div className='delete-button' onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) this.onCancel(item) } } />
@stuartaccent
stuartaccent / file-uploader.component.html
Last active March 18, 2021 16:24
Angular 7 file uploader with queue and progress using HttpClient, example https://stackblitz.com/edit/angular-7-file-upload-queue
<div class="row">
<div class="col-md-3">
<h3>Select files</h3>
<input type="file" #fileInput multiple (change)="addToQueue()" />
</div>
<div class="col-md-9">
<h3>Upload queue</h3>
<table class="table-headed table-striped">
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 2, 2024 15:55
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active December 29, 2023 00:40
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*