Skip to content

Instantly share code, notes, and snippets.

View silverwolfdoc's full-sized avatar
💯
I may be slow to respond.

silverwolfdoc

💯
I may be slow to respond.
View GitHub Profile
@silverwolfdoc
silverwolfdoc / main.go
Created July 25, 2021 13:35
Cloudfare Blog about Golang servers
&tls.Config{
// Causes servers to use Go's default ciphersuite preferences,
// which are tuned to avoid attacks. Does nothing on clients.
PreferServerCipherSuites: true,
// Only use curves which have assembly implementations
CurvePreferences: []tls.CurveID{
tls.CurveP256,
tls.X25519, // Go 1.8 only
},
}
@silverwolfdoc
silverwolfdoc / Paginate.svelte
Created July 11, 2021 18:27
Paginate Svelte
<script>
export let rows;
export let perPage;
export let trimmedRows;
$: totalRows = rows.length
$: currentPage = 0
$: totalPages = Math.ceil(totalRows / perPage)
$: start = currentPage * perPage
$: end = currentPage === totalPages - 1 ? totalRows - 1 : start + perPage - 1 ;
@silverwolfdoc
silverwolfdoc / Loader.svelte
Created July 1, 2021 17:10
Svelte native Loader with Tailwind
<script>
export let type = "circle";
</script>
{#if type == "line"}
<div class="flex justify-center items-center bg-transparent">
<div class="loader bg-indigo-100 p-5 rounded-full flex space-x-3">
<div class="w-5 h-5 bg-red-400 rounded-full animate-bounce" />
<div class="w-5 h-5 bg-red-400 rounded-full animate-bounce" />
<div class="w-5 h-5 bg-red-400 rounded-full animate-bounce" />
@silverwolfdoc
silverwolfdoc / Mesh.svelte
Created June 26, 2021 05:35
basic three.js in svelte
<script>
import { onMount } from "svelte";
let createScene;
let el;
onMount(async () => {
const module = await import("$lib/scene");
createScene = module.createScene;
createScene(el);
});
</script>
@silverwolfdoc
silverwolfdoc / index.html
Created June 18, 2021 07:04
tailwind Blurry gradient animated
<div class="flex items-center justify-center min-h-screen bg-gray-50">
<div class="relative w-full max-w-lg">
<div
class="absolute rounded-full animate-blob mix-blend-multiply filter blur-2xl opacity-70 -top-5 -right-2 w-72 h-72 bg-yellow-500"
/>
<div
class="absolute rounded-full animate-blob animation-delay-2000 mix-blend-multiply filter blur-2xl opacity-70 top-0 -left-2 w-72 h-72 bg-indigo-500"
/>
<div
@silverwolfdoc
silverwolfdoc / Tooltip.svelte
Created June 14, 2021 10:41
Svelte-tailwind tooltip
<script>
export let title = "";
let isHovered = false;
let x;
let y;
function mouseOver(event) {
isHovered = true;
x = event.pageX + 5;
y = event.pageY + 5;
@silverwolfdoc
silverwolfdoc / gist:85dbcf9f2e28f36c96da4724daf7a689
Created June 11, 2021 08:56
Tailwind add animated gradient
//add this to config
theme: {
extend: {
'animation': {
'gradient-x':'gradient-x 15s ease infinite',
'gradient-y':'gradient-y 15s ease infinite',
'gradient-xy':'gradient-xy 15s ease infinite',
},
'keyframes': {
'gradient-y': {
@silverwolfdoc
silverwolfdoc / index.svelte
Created May 28, 2021 22:48
svelte click outside a div
<script>
let name = 'world';
function clickOutside(node) {
const handleClick = event => {
if (node && !node.contains(event.target) && !event.defaultPrevented) {
node.dispatchEvent(
new CustomEvent('click_outside', node)
@silverwolfdoc
silverwolfdoc / connection.js
Created May 15, 2021 13:55
mongoose connection events
// CONNECTION EVENTS
mongoose.connection.on('connected', function () {
console.log('Mongoose connected');
});
mongoose.connection.on('error', function (err) {
console.log('Mongoose connection error: ' + err);
});
mongoose.connection.on('disconnected', function () {
console.log('Mongoose disconnected');
});
@silverwolfdoc
silverwolfdoc / index.js
Created May 15, 2021 13:29
Date functions
// DATE FORMATS
const months = {
0: 'January',
1: 'February',
2: 'March',
3: 'April',
4: 'May',
5: 'June',
6: 'July',
7: 'August',