Skip to content

Instantly share code, notes, and snippets.

View ChristianKienle's full-sized avatar
🐶
Coconut Shock

Christian Kienle ChristianKienle

🐶
Coconut Shock
  • Apple
  • Cupertino
View GitHub Profile
'use strict';
const { exec, spawnSync } = require('child_process');
const path = require('path');
const home = process.env['HOME'];
if(!home) {
console.error('home not set');
process.exit(1);
return;
# Add this to your zsh.rc-file
# Execute a Node Binary
function nbin() {
./node_modules/.bin/$@
}
# Execute and Debug Unit Tests
function njest() {
./node_modules/.bin/jest --clearCache && node --inspect-brk --no-lazy ./node_modules/.bin/jest . --runInBand --testTimeout 99999999 $@

Redundancy when using button groups

Let's say you want to mark a group of buttons as compactable. Instead of simpyl writing:

<div class="fd-button-group fd-is-compactable" role="group" aria-label="Group label">
  <button class="fd-button" aria-pressed="true">Left</button>
  <button class="fd-button">Middle</button>
 Right

Form items require special class depending on the type of input elements

If you have a form item with a text input element the HTML looks like this:

<div class="fd-form__item">
    <label class="fd-form__label" for="OatmD552">
        Normal Input:
    </label>
 
<template>
<div />
</template>
<script lang="ts">
import Vue from 'vue'
// Use these types in order to cast your props. Delete if not needed.
// import { PropValidator } from "vue/types/options";
// import { Prop } from "vue/types/options";
cd $(mktemp -d -t highway) && \
git clone -b master https://github.com/ChristianKienle/highway.git highway && \
./highway/scripts/bootstrap.sh
// a.m
@implementation XXX
- (BOOL)doX:(NSError **)error {
if([self success] == NO) {
if(error == NULL) {
log(bla);
}
}
}
@end
I am writing a command line tool which is using Process/NSTask
to launch $x. Internally $x is actually a bash script which
is using exec to execute $y.
Now the user sends SIGINT (ctrl+c in Terminal.app), my process
exits but $y is still running and writes stuff to stdout.
How can I properly handle this case? Usually I would have
just killed/interrupted/terminated $x (which I do) but this
seemingly does nothing. d'oh.😢😪
@ChristianKienle
ChristianKienle / A_Promise.swift
Last active May 18, 2018 09:10
simplest Promise framework possible?
public struct Promise<T> {
typealias Fulfiller = (T) -> (Void)
typealias Rejecter = (Void) -> (Void)
typealias Resolver = (_ fulfill: @escaping Fulfiller, _ reject: @escaping Rejecter) -> (Void)
let resolver: Resolver
init(_ resolver: @escaping Resolver){
self.resolver = resolver
}
func then<U>(_ execute: @escaping ((T) -> U)) -> Promise<U> {
return Promise<U>({(fulfill, reject) in
//
// PropertyList.swift
// CruiseKit
//
// Created by cmk on 15/07/16.
// Copyright © 2016 Christian Kienle. All rights reserved.
//
import Foundation