Skip to content

Instantly share code, notes, and snippets.

View casey-chow's full-sized avatar

Casey Chow casey-chow

View GitHub Profile
@blocka
blocka / wait-for-subscription.ts
Last active November 24, 2020 18:08
waitForSubscription helper function for testing graphql subscriptions
export function waitForSubscription<TResult, TContext>(schema: GraphQLSchema, subscription: DocumentNode, context: TContext) {
return new Promise<TResult | ReadonlyArray<GraphQLError>>(async resolve => {
const iterator = await subscribe(schema, subscription, {}, context)
if (isAsyncIterable(iterator)) {
for await (const next of iterator) {
const val: ExecutionResult<TResult> = next
if (val.errors) resolve(val.errors)
@jerieljan
jerieljan / How I Do PlantUML.md
Last active January 1, 2024 06:23
PlantUML with Style -- How I do PlantUML

I use PlantUML a lot. It's what I use for drawing all sorts of diagrams and it's handy because of its easy markup (once you get used to it) while making things easy to maintain as projects grow (thanks to version control)

This gist explains how I do my PlantUML workspace in a project.

  • The idea is to keep a globals directory for all diagrams to follow (like the "stylesheet" below) to keep things consistent.
  • I use a stylesheet.iuml file that keeps the use of colors consistent through use of basic FOREGROUND, BACKGROUND and ACCENT colors.
  • The style-presets.iuml file defines these colors so you can make "presets" or "themes" out of them.
  • As stated in the stylesheet.iuml, you'll need the Roboto Condensed and Inconsolata fonts for these to work properly.
  • You can choose to either run the PlantUML jar over your file/s, or use an IDE like VSCode with the PlantUML extension. Here's a preview of example-sequence.puml for example: https://imgur.com/Klk3w2F
@cmendesce
cmendesce / docker-compose.yml
Last active December 17, 2018 20:11
Compose file for metabase and postgress.
version: '3'
services:
metabase:
image: metabase/metabase
restart: always
depends_on:
- metabase-db
environment:
MB_DB_TYPE: postgres
@cklanac
cklanac / knexjs.joins.md
Created February 6, 2018 10:50
Knex.js Joins

Adding Knex to the endpoints

Now that you have a good understanding of the Knex's capabilities, let's look at adding Knex to our Express app endpoints. Quit the nodemon drills.js process and start the server.

Open Postman and navigate to http://localhost:8080/restaurants. You should get back a list of restaurants. The SELECT statement is straight forward, the only thing to point out is the addition of in the `.then(results => res.json(results) );

Inner Join

Let's tackle the grade first.

@stvhwrd
stvhwrd / hide-iterm-dock-icon.md
Last active November 3, 2023 16:18
Hide the iTerm dock icon on Mac OS X

Note: you can now configure this simply in iTerm2's application settings. Go to Preferences > Appearance > System and select "Exclude from Dock and ⌘-Tab Application Switcher".


On my dual-drive MacBook Pro I have remapped the eject key to F13 using Karabiner and NoEjectDelay. The eject key has been assigned as the hotkey for a guake-style visor terminal using iTerm2. Having its own hotkey precludes the need for an icon, so I prefer to hide the iTerm dock icon.

To hide the dock icon of iTerm2 on Mac OS X:

/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
@alej0varas
alej0varas / wagtailredirectpage.py
Created September 26, 2014 12:41
Wagtail redirect page. Can link to page, ulr and document.
# Thanks to Ethan Jucovy
# http://www.coactivate.org/projects/ejucovy/blog/2014/05/10/wagtail-notes-managing-redirects-as-pages/
# This model comes from wagtaildemo
class LinkFields(models.Model):
link_external = models.URLField("External link", blank=True)
link_page = models.ForeignKey(
'wagtailcore.Page',
null=True,
@WebReflection
WebReflection / process.nextTick.js
Created June 19, 2012 10:57
process.nextTick(callback) for browsers too
!function (window) {"use strict";
// by WebReflection - WTFPL License
var
prefixes = "r webkitR mozR msR oR".split(" "),
process = "process",
nextTick = "nextTick",
i = 0,
p = window[process] || (window[process] = {})
;
while (!p[nextTick] && i < prefixes.length)
@potomak
potomak / _flash.html.erb
Created January 12, 2012 14:35
Rails flash messages using Twitter bootstrap
<% [:notice, :error, :alert].each do |level| %>
<% unless flash[level].blank? %>
<div class="alert-message <%= flash_class(level) %>">
<a class="close" href="#">×</a>
<%= content_tag :p, flash[level] %>
</div>
<% end %>
<% end %>