Skip to content

Instantly share code, notes, and snippets.

View guncha's full-sized avatar

Guntars Ašmanis-Graham guncha

View GitHub Profile

Keybase proof

I hereby claim:

  • I am guncha on github.
  • I am gunchars (https://keybase.io/gunchars) on keybase.
  • I have a public key ASBbEYkROBziDJnCiVDviKygnWleN1pDDEYNI1I9aRMSTQo

To claim this, I am signing this object:

@guncha
guncha / react-typescript.md
Last active August 4, 2016 17:16 — forked from juhaelee/react-typescript.md
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)

@guncha
guncha / graphql-schema.coffee
Created March 23, 2016 16:39
GraphQL schema example using CoffeeScript
GraphQL = require("graphql")
GraphQLRelay = require("graphql-relay")
GraphQLUtilities = require("graphql/utilities")
__GREETING = "Hello World!"
Root = new GraphQL.GraphQLObjectType
name: "Root"
fields:
hello:
@guncha
guncha / index.js
Last active January 15, 2016 16:28
Example repo to demonstrate a caching issue with babel-relay-plugin-loader
var query = Relay.QL`
query {
viewer {
totalCount
}
}
`
console.log("The compiled Relay Query:", query)
@guncha
guncha / readme.md
Created December 10, 2015 20:08
Jasmine HTMLReporter stack traces using source maps

To get a quick and dirty stack traces with Jasmine's HTML Reporter, add this on the spec runner page after jasmine/boot.js.

<script type="text/javascript" src="sourcemapped-stacktrace.js"></script>
<script type="text/javascript">
  jasmine.getEnv().addReporter({
    jasmineDone: function() {
      var traces = document.querySelectorAll(".jasmine-stack-trace")
      for(var i = 0; i < traces.length; i++) {
 (function(node){
@guncha
guncha / relay.d.ts
Last active April 3, 2023 08:15
Very basic Relay typings for Typescript
declare module 'react-relay' {
// fragments are a hash of functions
interface Fragments {
[query: string]: ((variables?: RelayVariables) => string)
}
interface CreateContainerOpts {
initialVariables?: Object
prepareVariables?(prevVariables: RelayVariables): RelayVariables
@guncha
guncha / gist:2e41aa183ac7d2619cb1
Created July 6, 2015 00:01
Solver for the "Find odd-ball from a group of balls using a balance" problem
_ = require("underscore")
# State represents aggregate information we've learned about the set of balls.
# in the beginning, all of them are unknown. if they are on the heavier side of
# the balance, they become heavier or lighter if they're on the lighter side.
# if we've ruled them out as not the odd-ball, they become regular.
class State
constructor: (@unknown = 0, @heavier = 0, @lighter = 0, @regular = 0) ->
toString: -> [@unknown, @heavier, @lighter, @regular].toString()
size: -> @unknown + @heavier + @lighter + @regular

Auto-start PostgreSQL server on OSX with Homebrew

Below plist should go into ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist. LaunchAgent should pick it up on restart.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@guncha
guncha / gist:8551922
Created January 22, 2014 01:24
3 Dec - 21 Jan
21 22/Jan/2014 ||||||||||||||||||||||||||||||
53 21/Jan/2014 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
53 20/Jan/2014 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33 19/Jan/2014 |||||||||||||||||||||||||||||||||||||||||||||||
32 18/Jan/2014 ||||||||||||||||||||||||||||||||||||||||||||||
41 17/Jan/2014 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
51 16/Jan/2014 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
50 15/Jan/2014 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
53 14/Jan/2014 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
67 13/Jan/2014 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||