Skip to content

Instantly share code, notes, and snippets.

// Name: pull requests
import "@johnlindquist/kit";
const ghToken = await env('GH_TOKEN', 'Add your Github Personal Access Token');
const repo = 'johnlindquist/kit';
const [owner, name] = repo.split('/', 2);
const query = `
query pullRequests($owner: String!, $name: String!) {
@dsosby
dsosby / notgoodbye.ts
Created March 11, 2019 22:42
TypeScriptConditionalType
type NotGoodbye<T> = T extends "goodbye" ? never : T;
type Salutation = "hello" | "goodbye";
type AllPossibleWords = string
type AllPossibleWordsWithoutGoodbye = NotGoodbye<AllPossibleWords>
function neverSayBye(salutation: NotGoodbye<Salutation>, greetee: string) {
console.log(`${salutation} ${greetee}`)
}
neverSayBye('goodbye', 'David');
@dsosby
dsosby / PairSwap.c
Last active December 16, 2015 13:09
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node *next;
struct Node *prev;
} Node;
@dsosby
dsosby / gist:3756552
Created September 20, 2012 15:19
make-param-str
(defn make-param-str [param-map]
(join "&" (map (fn [[key val]] (format "%s=%s" (name key) val)) param-map)))
;TODO still needs URL encoding -- format wont work in clojurescript
@dsosby
dsosby / gist:3744784
Created September 18, 2012 18:15
ClojureScript Goodies
;Get all methods/properties of some object
(goog.object/getKeys some-object)
;Getting undefined errors? Use undefined? to probe
(undefined? load-namespace)
(undefined? str)
boolean isFoo() {
int status = this.getStatus();
return (status != STATUS_BAR &&
status != STATUS_BAZ);
}
vs.
boolean isFoo() {
@dsosby
dsosby / .taskrc
Created June 19, 2012 15:35
My TaskWarrior RC file
# [Created by task 2.0.0 6/5/2012 10:23:30]
# Taskwarrior program configuration file.
# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-faq',
# 'man task-tutorial', 'man task-color', 'man task-sync' or 'man taskrc'
# Here is an example of entries that use the default, override and blank values
# variable=foo -- By specifying a value, this overrides the default
# variable= -- By specifying no value, this means no default
# #variable=foo -- By commenting out the line, or deleting it, this uses the default
@dsosby
dsosby / gist:2255328
Created March 30, 2012 21:38
vimrc for work pc (win)
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
"behave mswin
if has('gui_running')
set guioptions-=T " no toolbar
colorscheme obsidian2
endif
@dsosby
dsosby / gist:2160486
Created March 22, 2012 17:33
JS Logging
var loglevel = 3;
function debug(message, level) {
level = level || 1;
if ( console ) {
if ( level >= loglevel ) {
console.log(message);
}
}
}
@dsosby
dsosby / gist:1823881
Created February 14, 2012 05:26
Jsonp & Clojurescript
(def tumblr-url "http://pipes.yahoo.com/pipes/pipe.run?_id=4ddef10340ec6ec0374cbd0f73bce819&_render=json")
(defn display-count [json-obj]
(let [data (js->clj json-obj :keywordize-keys true)
post-count (:count data)]
(js/alert (str "Number of posts: " post-count))))
(defn display-items [json-obj]
(let [data (js->clj json-obj :keywordize-keys true)
items (:items (:value data))