Skip to content

Instantly share code, notes, and snippets.

View damianof's full-sized avatar
😁

Damiano Fusco damianof

😁
View GitHub Profile
@damianof
damianof / segment.ts
Last active March 13, 2024 21:00
Attempt to optimize Tailwind CSS v4 util function "segment"
const funcAnyClosingCase = (char: string, cbs: string, idx: number): { cbs: string, idx: number } => {
const cbsCount = cbs.length - 1
if (
cbs.length > 0 && char === cbs[cbsCount]
) {
cbs = cbs.slice(0, cbsCount)
}
return { cbs, idx }
}
@damianof
damianof / tailwind-colors-as-css-variables.md
Created February 2, 2024 13:17 — forked from Merott/tailwind-colors-as-css-variables.md
Expose Tailwind colors as CSS custom properties (variables)

This is a simple Tailwind plugin to expose all of Tailwind's colors, including any custom ones, as custom css properties on the :root element.

There are a couple of main reasons this is helpful:

  • You can reference all of Tailwind's colors—including any custom ones you define—from handwritten CSS code.
  • You can define all of your colors within the Tailwind configuration, and access the final values programmatically, which isn't possible if you did it the other way around: referencing custom CSS variables (defined in CSS code) from your Tailwind config.

See the Tailwind Plugins for more info on plugins.

@damianof
damianof / Deskree
Last active January 12, 2023 20:15 — forked from 3aluw/Deskree
import { reactive, ref, onMounted } from 'vue'
export const useDeskree = (props) => {
const userInfo = ref({})
//the user object that has some user functions such as login ...
const user = {
get() {
return loggedInUser
},
const { DateTime } = require('luxon')
const test1 = () => {
let startIsoDate = '2024-02-28T00:00:00.000Z'
let expected = '2023-02-28T00:00:00.000Z'
let result = DateTime.fromISO(startIsoDate, { zone: 'UTC' }).toUTC().plus({
year: -1
}).toISO()
console.assert(expected !== result, 'test1 Failed')
@damianof
damianof / gist:41192274852d895d696b14ca62562126
Created September 1, 2022 14:14
date-fns add days bug for 2022-03-13
// note: this is a gist to show how to replicate the issue reported on https://github.com/date-fns/date-fns/issues
const { add } = require('date-fns')
const initialIsoDateString = '2022-03-13T00:00:00.000Z'
const expectedIsoDateString = '2022-03-14T00:00:00.000Z' // we expected this, but instead get 2022-03-13T23:00:00.000Z
const expectedDate = new Date(expectedIsoDateString)
const dateFnsDurationParams = {
days: 1 // we want to add one day
@damianof
damianof / tweet_dumper.py
Created July 4, 2020 13:52 — forked from onmyeoin/tweet_dumper.py
A script to download all of a user's tweets into a csv
#!/usr/bin/env python
# encoding: utf-8
import tweepy
import csv
def get_all_tweets(screen_name):
consumer_key = ""
consumer_secret = ""
@damianof
damianof / Chapter01-HomeView-03.vue
Last active February 28, 2020 14:22
Chapter 1 - Home view 2 - updated
<template>
<div class="home">
<ItemsListComponent :items="items" />
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import ItemsListComponent from '@/components/items/ItemsList.component.vue'
@damianof
damianof / Chapter01-HomeView-02.vue
Last active February 27, 2020 20:57
Chapter 1 - Home view 2 - removed preliminary code
<template>
<div class="home">
</div>
</template>
<script lang="ts">
</script>
@damianof
damianof / Chapter01-HomeView-01.vue
Last active February 27, 2020 20:57
Chapter 1 - Home view 1 - default code created by vue-cli
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
@damianof
damianof / Chapter01-ItemsListComponent-01.vue
Last active February 27, 2020 20:58
Chapter 1 - ItemsList component 1 - initial draft
<template>
<div>
<h3>My Items:</h3>
<ul>
<li v-for="item in items" :key="item.id">
{{ item.name }}
</li>
</ul>
</div>
</template>