Skip to content

Instantly share code, notes, and snippets.

@antony
antony / SimpleFileUploader.svelte
Created September 18, 2019 16:03
File Uploader Svelte
<label>
{#if uploading}
<Progress bind:percent={progress} text="Uploading..." />
{:else if processing}
<Progress percent={100} text="Processing..." />
{:else}
<slot name="content">
</slot>
{/if}
<input
import { describe, it } from 'mocha';
import { expect } from 'chai';
import Nav from '../../src/components/Nav.html';
import { getByText } from 'dom-testing-library';
describe('first test', () => {
it('should be testable', () => {
let nav = new Nav({
target: document.body
});
@mrkishi
mrkishi / svelte.d.ts
Created October 22, 2018 03:33
Project-wide Svelte components type declaration for vscode
declare module '*.svelte' {
type Data = { [key]: any }
type Changed = { [key]: boolean }
type Listener = { cancel: () => void }
export default class Component {
root: Component
options: Data
constructor(init: { target: Element, data: Data })
@veered
veered / tracker.js
Last active May 28, 2019 22:12
Some bonus features for Tracker
// Only trigger enclosing computation if the return value of
// f is not EJSON.equals to the previuous return value
Tracker.guard = function(f) {
if (Meteor.isServer || !Tracker.currentComputation) {
return f();
}
let dep = new Tracker.Dependency(),
curView = Blaze.currentView,
tplFunc = Template._currentTemplateInstanceFunc;
@paulirish
paulirish / what-forces-layout.md
Last active May 30, 2025 17:05
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 31, 2025 06:10
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname