Skip to content

Instantly share code, notes, and snippets.

View trmcnvn's full-sized avatar
✌️

Thomas McNiven trmcnvn

✌️
View GitHub Profile
@trmcnvn
trmcnvn / git-slim.ps1
Last active November 7, 2019 12:34
pshazz
try { Get-Command git -ea stop > $null } catch { return }
function pshazz:git-slim:init {
$git = $global:pshazz.theme.git
$dirty = $git.prompt_dirty
$unstaged = $git.prompt_unstaged
$staged = $git.prompt_staged
$stash = $git.prompt_stash
@trmcnvn
trmcnvn / object.js
Last active December 23, 2021 21:59
Reuse IntersectionObserver's
export function sortObject(object) {
Object.keys(object).reduce((prev, curr) => {
if (object[curr] !== null && typeof object[curr] === 'object') {
prev[curr] = sortObject(object[curr]);
return prev;
}
prev[curr] = object[curr];
return prev;
}, {});
}
{"version":2,"type":"full","values":{"p:0:chat.scroller.freeze":1,"p:0:chat.subs.merge-gifts":5,"p:0:layout.discover":true,"p:0:chat.filtering.highlight-tokens":true,"p:0:chat.viewer-cards.color":"#F8E71C","p:0:metadata.player-stats":true,"p:0:chat.filtering.show-deleted":true,"p:0:player.ext-interaction":false,"p:0:player.no-autoplay":true,"p:0:metadata.uptime":1,"p:0:channel.raids.no-autojoin":false,"cfg-seen":["i18n.debug.transform","socket.use-cluster","chat.actions.reasons","chat.actions.inline","chat.actions.rules-as-reasons","chat.badges.hidden","chat.badges.custom-mod","chat.badges.style","chat.fix-bad-emotes","chat.click-emotes","chat.sub-emotes","chat.emote-dialogs","chat.scrollback-length","chat.delay","chat.emoji.style","chat.font-size","chat.font-family","chat.width","chat.lines.emote-alignment","chat.timestamp-format","chat.lines.alternate","chat.lines.padding","chat.lines.borders","chat.rich.enabled","chat.rich.hide-tokens","chat.rich.all-links","chat.rich.minimum-level","chat.filtering.click-t
@trmcnvn
trmcnvn / Premake.rb
Last active February 17, 2019 13:30
Premake 5 for Linuxbrew
class Premake < Formula
desc "Write once, build anywhere Lua-based build system"
homepage "https://premake.github.io/"
url "https://downloads.sourceforge.net/project/premake/Premake/4.4/premake-4.4-beta5-src.zip"
sha256 "0fa1ed02c5229d931e87995123cdb11d44fcc8bd99bba8e8bb1bbc0aaa798161"
version_scheme 1
head "https://github.com/premake/premake-core.git"
bottle do
cellar :any_skip_relocation
@trmcnvn
trmcnvn / directives.ts
Created February 8, 2019 21:02
GraphQL Directive example
import { SchemaDirectiveVisitor } from 'graphql-tools';
import { defaultFieldResolver, GraphQLField, GraphQLResolveInfo } from 'graphql';
import { ForbiddenError } from '../errors';
import { ContextParameters } from 'graphql-yoga/dist/types';
// Throws an error if the query requested a field that is marked by this directive
// and the requested user is not the authenticated user.
export default class OwnerDirective extends SchemaDirectiveVisitor {
visitFieldDefinition(field: GraphQLField<any, any>) {
this.checkIfOwner(field);
04:35:59.714 POST https://kitsu.io/api/edge/posts [HTTP/2.0 201 Created 1590ms]
04:36:01.875 PATCH https://kitsu.io/api/edge/uploads/26756 [HTTP/2.0 200 OK 318ms]

# => https://kitsu.io/api/edge/uploads/26756
# => uploadOrder: 1
action(query) {
const options = Object.assign({ cache: true }, query.options);
let key = Object.assign({}, query.expression, options);
key = JSON.stringify(sortObject(key));
const value = QUERY_CACHE[key];
if (value) {
if ((new Date()) > value) {
delete QUERY_CACHE[key];
} else {
@trmcnvn
trmcnvn / keybase.md
Created May 29, 2018 02:05
Keybase Proof

Keybase proof

I hereby claim:

  • I am trmcnvn on github.
  • I am vevix (https://keybase.io/vevix) on keybase.
  • I have a public key whose fingerprint is 5339 A16C 444A 97BC 032F 2380 8962 FE71 D808 7F83

To claim this, I am signing this object:

import Ember from 'ember';
import Changeset from 'ember-changeset';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
this.model = new Ember.Object({ inputValue: 'Hello, World!' });
this.changeset = new Changeset(this.model, this.validate);