Skip to content

Instantly share code, notes, and snippets.

View dasilvacontin's full-sized avatar
🔥
Doing it

David da Silva dasilvacontin

🔥
Doing it
View GitHub Profile
type Safe<T> = { [P in keyof T]: string };
function getSafeEnvironment<T extends {}>(e: T): Safe<T> {
return new Proxy(e, {
get: function(env: any, key: string): string {
const value: any = env[key];
if (value == null) {
throw new Error("'" + key + "' environment variable is not set.");
}
return value;
@jesperorb
jesperorb / cors.md
Last active February 21, 2024 14:17
Handle CORS Client-side

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin
@WengerK
WengerK / README.md
Last active February 3, 2021 10:47
MacOS - Trigger Notification Center when long running commands finishes

Article Ressources - MacOS - Trigger Notification Center when long running commands finishes

This is the Gist repository for my article MacOS - Trigger Notification Center when long running commands finishes.

Be aware that this article has been wrote for the Blog of Antistatique — Web Agency in Lausanne, Switzerland. A place where I work as Full Stack Web Developer.

Feel free to read it the full article on Medium or check it out on Antistatique.

@paulirish
paulirish / what-forces-layout.md
Last active April 29, 2024 16:45
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
@holman
holman / tmobile.sh
Created June 29, 2015 21:32
Will someone destroy Comcast already
# Manually download each month's call history from t-mobile.com and toss them in
# a directory. Or do it automatically using computers, who cares.
#
# Install spark: https://github.com/holman/spark
cat * | grep 266-2278 | sort | cut -d, -f5 | spark
# ▂█▁▃▅
echo "fuck comcastttttttttttttttttttttttttttttttttttttttttt"
# ⒻⓊⒸⓀ ⒸⓄⓂⒸⒶⓈⓉ
@greggman
greggman / use-strict.md
Last active August 29, 2015 14:18
Can it really be right that strict mode in JavaScript can break your code?

So I had a sample that wasn't working in firefox. It had code like ths

"use strict";
var devicePixelRation = window.devicePixelRatio || 1;

That worked fine on Chrome but broke on Firefox with

TypeError: setting a property that has only a getter

So first thing I learned something I didn't know. Variables declared with var in the global scope

@jirutka
jirutka / -README.md
Last active October 31, 2023 09:07
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings
@potiuk
potiuk / libmemcached.rb
Last active December 29, 2020 10:07
Install libmemcached with brew in preview (build 13A558) version of OSX Mavericks with XCode 5 Developer Preview 6
require 'formula'
class Libmemcached < Formula
homepage 'http://libmemcached.org'
url 'https://launchpad.net/libmemcached/1.0/1.0.17/+download/libmemcached-1.0.17.tar.gz'
sha1 '1023bc8c738b1f5b8ea2cd16d709ec6b47c3efa8'
depends_on 'memcached'
def install
@AngryAnt
AngryAnt / DualDisplay.cs
Last active January 24, 2024 08:26
Example use of the Unity 4.1 AirPlay API - gives a setup with the iOS device as controller of the remote display.
using UnityEngine;
using System.Collections;
/*
Runtime use:
To be available, AirPlay needs to be switched on for the device either via a native AirPlay UI component or
via the global AirPlay mirroring setting. Your options are:
A: Modify your Xcode project to layer a native AirPlay Cocoa control somewhere over your Unity content.
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le