Skip to content

Instantly share code, notes, and snippets.

View inorganik's full-sized avatar
🛠️
building

Jamie Perkins inorganik

🛠️
building
View GitHub Profile
@inorganik
inorganik / 00-tailwind-v4-with-angular.sh
Last active May 3, 2024 17:51
Tailwind v4 in Angular 17
# STEP 1
#
# Install tailwind. We need the force flag because the angular builder
# has a peer dependency on tailwind ^2.0.0 || ^3.0.0
# Issue to address this: https://github.com/angular/angular-cli/issues/27585
#
$ npm i -D tailwindcss@next @tailwindcss/postcss@next --force
# STEP 2
#
@inorganik
inorganik / app.js
Last active March 31, 2024 21:13
Using CountUp.js in React
import { useEffect, useRef } from 'react'
// playground: https://stackblitz.com/edit/react-ts-nv5fxe?file=App.tsx
export default function App() {
// create a ref and declare an instance for each countUp animation
const countupRef = useRef(null);
let countUpAnim;
@inorganik
inorganik / randomLocations.swift
Created June 22, 2017 14:37
Return a cluster of random locations around a given location
import Foundation
import CoreLocation
struct randomLocations {
// create random locations (lat and long coordinates) around user's location
func getMockLocationsFor(location: CLLocation, itemCount: Int) -> [CLLocation] {
func getBase(number: Double) -> Double {
return round(number * 1000)/1000
@inorganik
inorganik / app.svelte
Last active August 19, 2023 13:23
CountUp.js with Svelte!
<script>
/**
* You can use CountUp directly like this:
*/
import { onMount } from 'svelte';
import { CountUp } from 'countup.js';
let targetEl, countUpAnim
onMount(() => {
@inorganik
inorganik / countUp-jquery.js
Last active June 28, 2023 22:03
A CountUp extension for jQuery
// Dependency: CountUp.js: https://github.com/inorganik/CountUp.js
(function ($) {
$.fn.countup = function (params) {
// make sure dependency is present
if (typeof CountUp !== 'function') {
console.error('countUp.js is a required dependency of countUp-jquery.js.');
return;
}
@inorganik
inorganik / email-subscribe-form.component.ts
Last active May 19, 2022 07:19
MailChimp subscribe form with Angular 5 using jsonp
import { Component } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { HttpClient, HttpParams } from '@angular/common/http';
interface MailChimpResponse {
result: string;
msg: string;
}
@Component({
@inorganik
inorganik / getUsersLocale.ts
Created August 26, 2019 18:24
Angular: get user's language and locale
getUsersLocale(defaultValue: string): string {
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') {
return defaultValue;
}
const wn = window.navigator as any;
let lang = wn.languages ? wn.languages[0] : defaultValue;
lang = lang || wn.language || wn.browserLanguage || wn.userLanguage;
return lang;
}
@inorganik
inorganik / angular-validators.ts
Created April 30, 2021 22:17
Angular validators
import {
AbstractControl,
AsyncValidatorFn,
ValidationErrors,
ValidatorFn,
Validators,
} from '@angular/forms';
export class CustomValidators {
@inorganik
inorganik / thunderclap.js
Last active March 31, 2021 08:50
Smash Medium's clap button the max number of times (50) in 1 second
// smash Medium's clap button the max number of times
function simulateClick(node) {
var md = document.createEvent('MouseEvents');
md.initEvent('mousedown', true, false);
node.dispatchEvent(md);
var mu = document.createEvent('MouseEvents');
mu.initEvent('mouseup', true, false);
node.dispatchEvent(mu);
}
@inorganik
inorganik / cloudSettings
Last active July 17, 2020 20:24
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-07-17T20:23:56.317Z","extensionVersion":"v3.4.3"}