Skip to content

Instantly share code, notes, and snippets.

@jan-heise
jan-heise / readme.md
Created Apr 22, 2020
Enable Darkmode Variants in TailwindUI depending on OS / Browser Settings
View readme.md

Enable Darkmode Variants in TailwindUI depending on OS / Browser Settings

To enable darkmode variants simply add the following lines to the theme/extend section of your tailwind config

screens: {
    'dark-mode': {'raw': '(prefers-color-scheme: dark)'},
},

This enables the dark-mode variant for your classes. You are now able to use dark-mode:bg-gray-900 on your site.

@tigt
tigt / git-branch-to-favicon.js
Created Mar 18, 2020
Creates an SVG string that can be used as a favicon across different Git branches. Actually getting this into the browser is sadly project-specific.
View git-branch-to-favicon.js
const { execSync } = require('child_process')
const { createHash } = require('crypto')
const invertColor = require('invert-color')
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
const hash = createHash('sha256')
hash.update(branchName)
const color = '#' + hash.digest().toString('hex').substring(0, 6)
const invertedColor = invertColor(color, true)
@nicbet
nicbet / Dockerfile
Created Jun 27, 2019
Elixir 1.9 Releases Alpine Linux Docker Multi-Stage Build
View Dockerfile
# ---- Build Stage ----
FROM erlang:22-alpine AS app_builder
# Set environment variables for building the application
ENV MIX_ENV=prod \
TEST=1 \
LANG=C.UTF-8
# Fetch the latest version of Elixir (once the 1.9 docker image is available you won't have to do this)
RUN set -xe \
@sergeycherepanov
sergeycherepanov / blog.example.com.toml
Last active Jan 5, 2021
Traefik Systemd Example with letsencrypt
View blog.example.com.toml
# /etc/traefik/conf.d/blog.example.com.toml
[frontends.blog]
backend = "blog"
passHostHeader = true
entrypoints = ["https", "http"]
priority = 100
[frontends.blog.ratelimit]
extractorfunc = "client.ip"
[frontends.blog.ratelimit.rateset.rateset1]
period = "10s"
@josephan
josephan / setup_tailwind_in_phoenix.md
Last active Oct 9, 2021
Add Tailwind CSS to an Elixir/Phoenix Project with PurgeCSS
View setup_tailwind_in_phoenix.md
@LouisCAD
LouisCAD / GooglePlayServices.kt
Created Nov 23, 2017
Allows using Google Play Services Task API in Kotlin Coroutines, plus Play Services availability check made easier.
View GooglePlayServices.kt
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.Task
import splitties.init.appCtx
import kotlin.coroutines.experimental.suspendCoroutine
val googleApiAvailability = GoogleApiAvailability.getInstance()!!
inline val playServicesAvailability get() = googleApiAvailability.isGooglePlayServicesAvailable(appCtx)
@JvmName("awaitVoid")
suspend fun Task<Void>.await() = suspendCoroutine<Unit> { continuation ->
View KtorApp.kt
package main
import com.zaxxer.hikari.HikariDataSource
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.mapping.Environment
import org.apache.ibatis.session.Configuration
import org.apache.ibatis.session.SqlSession
import org.apache.ibatis.session.SqlSessionFactory
import org.apache.ibatis.session.SqlSessionFactoryBuilder
@yowu
yowu / HttpProxy.go
Last active Dec 2, 2021
A simple HTTP proxy by Golang
View HttpProxy.go
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@artem-zinnatullin
artem-zinnatullin / GradleWorkersPleaseStopTakingFocus.gradle
Created Jul 21, 2015
Prevent Gradle Workers from taking focus! #DevelopersLikeComfort
View GradleWorkersPleaseStopTakingFocus.gradle
// You can place it in the root build.gradle
allprojects {
tasks.withType(JavaForkOptions) {
// Forked processes like GradleWorkerMain for tests won't steal focus!
jvmArgs '-Djava.awt.headless=true'
}
}