Skip to content

Instantly share code, notes, and snippets.

View blacktaxi's full-sized avatar
🇺🇦
russia is a terrorist state, russians are a terrorist nation

Serhii Yavnyi blacktaxi

🇺🇦
russia is a terrorist state, russians are a terrorist nation
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
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
@toburger
toburger / reflector.fsx
Last active August 29, 2015 14:25
Cool new F# 4.0 feature
module Reflection =
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open System.Reflection
let private (|Name|) (info: MemberInfo) = info.Name
let private (|PropertyName|_|) = function
| PropertyGet (_, Name name, _) -> Some name
| _ -> None
@Thimoteus
Thimoteus / settimeout.purs
Last active August 29, 2015 14:23
Synchronous setTimeout with Purescript and the ContT monad
module Main where
import Data.Function
import Debug.Trace
import Control.Monad.Trans
import Control.Monad.Cont.Trans
import Control.Monad.Eff
foreign import data Timeout :: !
type Milliseconds = Number
#!/bin/bash -e
name=$(sed -n -e 's/^[nN]ame:\s\+\(.\+\)/\1/p' *.cabal)
old_ver=$(sed -n -e 's/^[vV]ersion:\s\+\(.\+\)/\1/p' *.cabal)
has_docs=1
grep -i '^Library' *.cabal || has_docs=0
echo "Package name: $name"
echo "Current version: $old_ver"
echo "Has documentation: $has_docs"
@anaisbetts
anaisbetts / analytics.js
Created January 7, 2015 20:47
Google Analytics in Atom Shell
// Pretend that cookies work
(function (document) {
var cookies = {};
document.__defineGetter__('cookie', function () {
var output = [];
for (var cookieName in cookies) {
output.push(cookieName + "=" + cookies[cookieName]);
}
return output.join(";");
});
@paf31
paf31 / 24days.md
Last active August 8, 2023 05:53
24 Days of PureScript

This blog post series has moved here.

You might also be interested in the 2016 version.

@paf31
paf31 / node-haskell.md
Last active April 14, 2021 18:42
Reimplementing a NodeJS Service in Haskell

Introduction

At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.

Over the past few months, I have been working on two Haskell services:

  • A reimplementation of an existing socket.io service, previously written for NodeJS using TypeScript.
  • A new service, which would interact with third-party components using standard data formats from the medical industry.

I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces

namespace WebSocket
// Appache 2.0 license
// References:
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py
// [4] WebSockets Organising body http://www.websocket.org/echo.html
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664
@gusty
gusty / zipIndex.fsx
Last active August 29, 2015 14:01
Solve stack overflow in zipIndex function.
#r @"c:/packages/FsControl.1.0.9/lib/net40/FsControl.Core.dll"
open FsControl.Core.TypeMethods
open FsControl.Core.Types
open FsControl.Operators
type MonadBuilder() =
member inline b.Return(x) = result x
member inline b.Bind(p,rest) = p >>= rest
member b.Let (p,rest) = rest p
@cartazio
cartazio / xcode5-haskell-directions.md
Last active May 28, 2019 00:35
xcode 5 + OS X 10.9 mavericks GHC work around nuttiness

PSA :

just use GHC for OSX https://ghcformacosx.github.io

the rest of these directions are preserved for historical purposes

TLDR version, if you have homebrew

xcode-select --install ; brew tap homebrew/versions ;   brew tap homebrew/dupes \