Skip to content

Instantly share code, notes, and snippets.

https://stackblitz.com/edit/vitejs-vite-7jecmd?file=vite.config.ts
@codler
codler / .md
Last active October 12, 2020 10:20

New OS

sudo apt update
sudo apt full-upgrade

Check most used disk usage by folder

sudo du -a / 2>/dev/null | sort -n -r | head -n 20

Save space

sudo apt clean
uname -r
@codler
codler / useInViewport.tsx
Last active September 11, 2024 07:28
React hook check if element is in viewport
import { useState, useEffect, RefObject, useCallback } from "react";
function isElementInViewport(el: Element) {
var rect = el.getBoundingClientRect();
return (
rect.bottom >= 0 &&
rect.right >= 0 &&
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.left <= (window.innerWidth || document.documentElement.clientWidth)
@codler
codler / result.html
Created September 9, 2017 08:27
Code in the dark - NordicJS - 2017
<!doctype html>
<style>
* {
margin: 0;
padding: 0;
font-size: 16px;
}
.hejsan {
position:relative;
}

Requirements

  • node
  • npm
  • yarn

First time computer setup

brew install watchman
sudo npm install -g react-native-cli

Create project

@codler
codler / scrollToElement.ts
Last active June 25, 2020 09:32
Smooth scrollToElement
function scrollTo(targetPosition: number, scrollDistance: number, duration: number, easing: Function) {
let time = 0;
const minTime = 0;
const diff = Math.max(Math.min(scrollDistance, 100), -100);
if (diff === 0) {
return;
}
for (let i = 0, len = Math.abs(diff); i <= len; i++) {
@codler
codler / aktie_fetch.php
Last active November 20, 2015 17:22
Aktie SMS notifikation 2010-04-10
<?php
require_once("connection.php");
$data = urldecode($_POST['data']);
$data = explode("|", $data);
$arr = array();
$alert = array();
foreach ($data AS $v) {
$a = explode("=", $v);
if (is_numeric($a[1])) {
@codler
codler / gist:c91bc144a822c3fb0fc2
Last active January 9, 2018 17:35
Ractive.extend options as TypeScript Class - http://jsfiddle.net/qnjgsq1L/
function RactiveExtendTypeScriptClass(tsClass: any): RactiveStatic {
var instance = new tsClass();
var r = {};
for (var key in instance) {
r[key] = instance[key];
}
return Ractive.extend(r);
}
interface RactiveComponentPlugins {
@codler
codler / css-supports.js
Last active October 8, 2022 09:32
CSS.supports() Polyfill
/*! CSS.supports() Polyfill
* https://gist.github.com/codler/03a0995195aa2859465f
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
if (!('CSS' in window)) {
window.CSS = {};
}
if (!('supports' in window.CSS)) {
window.CSS._cacheSupports = {};
window.CSS.supports = function(propertyName, value) {
@codler
codler / flex.less
Last active October 7, 2023 07:01
Prefix flex for IE10 and Safari / iOS in LESS
/*! Prefix flex for IE10 and Safari / iOS in LESS
* https://gist.github.com/codler/2148ba4ff096a19f08ea
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
.display(@value) when (@value = flex) {
display: -ms-flexbox; // IE10
display: -webkit-flex; // Safari / iOS
}
.display(@value) when (@value = inline-flex) {