Skip to content

Instantly share code, notes, and snippets.

View morajabi's full-sized avatar

Mo morajabi

View GitHub Profile
@alii
alii / ensure-keys.ts
Created August 25, 2021 14:12
Infer object values while strictly specifying keys in TypeScript
/**
* TypeScript currently lacks a way of typing a record of keys only but not values.
* we need this because we want an object of typed keys but we want to leave the values inferred.
* thankfully, we can do this with generics. This function allows the second generic's values to be inferred
* so that our object is fully type safe for hugely complex types, but we can guarantee that all the keys we need exist.
* It's not perfect, but it gets the job done for the time being
*/
export function ensureKeys<T>() {
/**
* Function that returns the value that gets put in, values are type-safely inferred
@surpher
surpher / rust_to_swift.md
Last active April 11, 2025 03:03
Building binaries from Rust to iOS/macOS (PactSwift specific)
@nickffox
nickffox / Keyboard.swift
Created August 16, 2019 18:43
Adjusting a SwiftUI View for the Keyboard.
import Combine
final class Keyboard: ObservableObject {
// MARK: - Published Properties
@Published var state: Keyboard.State = .default
// MARK: - Private Properties
@timothycosta
timothycosta / UIScrollViewWrapper.swift
Created July 5, 2019 03:25
UIScrollView wrapped for SwiftUI
//
// UIScrollViewWrapper.swift
// lingq-5
//
// Created by Timothy Costa on 2019/07/05.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI
@jarrodthibodeau
jarrodthibodeau / now.json
Created May 2, 2019 21:46
now.json 2.0 static configuration to get your grade on securityheaders.com to an A (only for root path)
{
"version": 2,
"name": "PROJECT_NAME_HERE",
"alias": [
"YOUR_ALIASES_HERE"
],
"routes": [
{
"src": "/",
"headers": {
@WesSouza
WesSouza / zeit-now-g-suite-setup.md
Last active March 27, 2019 18:23 — forked from jaydenseric/zeit-now-g-suite-setup.md
Zeit Now G Suite setup

Run each of the following lines, replacing yourdomain.com and AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA with your details:

export NOW_DOMAIN=yourdomain.com
export GOOGLE_VERIFICATION=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
now dns add "$NOW_DOMAIN" @ TXT "google-site-verification=$GOOGLE_VERIFICATION"
now dns add "$NOW_DOMAIN" @ MX ASPMX.L.GOOGLE.COM 1
now dns add "$NOW_DOMAIN" @ MX ALT1.ASPMX.L.GOOGLE.COM 5
now dns add "$NOW_DOMAIN" @ MX ALT2.ASPMX.L.GOOGLE.COM 5
now dns add "$NOW_DOMAIN" @ MX ALT3.ASPMX.L.GOOGLE.COM 10
@threepointone
threepointone / for-snook.md
Last active December 3, 2024 21:48
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@arashmilani
arashmilani / twitter-activity-tweets-remover.js
Last active May 26, 2019 11:06
Twitter "activity tweets" remover
// ==UserScript==
// @name twitter-activity-tweets-remover
// @namespace http://arashmilani.com/
// @version 0.1
// @description Twitter "activity tweets" remover
// @author Arash Milani
// @match https://*twitter.com/*
// @grant none
// ==/UserScript==
function isOk(input) {
if (Array.isArray(input)) return input.length > 0;
if (typeof input === 'object' && input) return Object.keys(input).length > 0;
if (typeof input === 'number') return true;
return Boolean(input);
}
@tlakomy
tlakomy / jQuery>React.markdown
Last active August 17, 2022 12:08
Let's not forget about jQuery

In this talk I'd like to use 5 minutes of my time to explain to the audience why jQuery is simply way better than React.

  • Does React have a fadeIn() method? Nah, I don't think so. You need to install a react-transition-group package which weighs over 3GB.
  • Can you do $.get(https://stackoverflow.com/questions/12345/adding_two_numbers_javascript) in React? NOPE.
  • Remember React 3.3.1? Me neither, because they didn't make it. Meanwhile in jQuery land: https://code.jquery.com/jquery-3.3.1.min.js
  • Can you learn jQuery for free? Sure! Can you learn React for free? It'll be $500 USD and your left kidney for a conference ticket.

And many, many more.

(This is a completely serious lightning talk proposal, I promise.)