Skip to content

Instantly share code, notes, and snippets.

View andormade's full-sized avatar
👋

Andor Polgár andormade

👋
View GitHub Profile
@orta
orta / rfc.md
Last active February 20, 2024 02:23
A proposal for improving TS2322 error messages

This is a work in progress. Please don't take this as something that will definitely happen, we all know what happens to well laid plans and I need to present it to the rest of the TypeScript team in order to figure out a lot of feasibility questions.

Intro

The examples in this PR assumes [CLI DX] Improve positioning of compiler error messaging info #45717 is merged

In 4.4, all diagnostic messages from TypeScript are treated the same, we have a massive .JSON file of ±2000 diagnostic messages which are used everywhere from compiler messages to CLI help. Aside from some simple string manipulation, these are effectively what we output for all error messages. I'd like to propose that we break this pattern, just for error TS2322.

TS2322 is our 'type x is not assignable to y' error, you'd see it for const str: string = 123 and I expect it is the most seen

@tkrotoff
tkrotoff / FrontendFrameworksPopularity.md
Last active May 2, 2024 03:18
Front-end frameworks popularity (React, Vue, Angular and Svelte)
@andormade
andormade / hungariandate.liquid
Last active August 26, 2016 23:28
It does Hungarian date format for Liquid templates
{% comment %}
Usage: {% include hungariandate.liquid date=post.date %}
or: {% include hungariandate.liquid date=page.date %}
2016 Andor Polgar (andor.cool)
{% endcomment %}
{{ include.date | date: "%Y." }}

All code is in JavaScript, but the technique discussed is applicable to many languages.

50% of "else" statements are unnecessary. Not only that, they also increase bugs and decrease readability and maintainability. A coding technique to counter this is "guard clauses". Using them has the following benefits:

  • Thinking in terms of guard clauses instead of if/else puts you in a frame of mind where you are more likely to catch bugs.
  • This pattern increases code readability (and thus maintainability)
  • It Keeps Code Left, which again increases readability
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@andormade
andormade / main.c
Created November 12, 2011 18:00
Audio Queue example
#include <stdlib.h>
#include <math.h>
#include <AudioToolbox/AudioQueue.h>
#include <CoreAudio/CoreAudioTypes.h>
#include <CoreFoundation/CFRunLoop.h>
#define NUM_CHANNELS 2
#define NUM_BUFFERS 3
@andormade
andormade / midinotenumbers.h
Created November 11, 2011 22:01
MIDI note numbers
#ifndef __MIDI_NOTE_NUMBERS__
#define __MIDI_NOTE_NUMBERS__
#define A0 21
#define As0 22
#define Bb0 22
@Solution
Solution / Regpx.h
Created November 11, 2011 20:20
My C version of preg_match()
/*
* File: Regxp.h
* Author: solution
*
* Created on 11. listopad 2011, 16:00
*/
#include <stdio.h>
#include <string.h>
#include <pcre.h>