Skip to content

Instantly share code, notes, and snippets.

@caseywatts
caseywatts / 0 README.md
Last active May 2, 2024 06:06
d3 & c3 npm shim to es6 module for Ember
@adharris
adharris / postgres_array.go
Created November 28, 2012 19:52
PostgreSQL demo of Array types using Golang
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@stevedomin
stevedomin / create_post.exs
Last active July 12, 2023 01:32
Using UUIDs as primary key with Ecto
defmodule MyBlog.Repo.Migrations.CreatePost do
use Ecto.Migration
def change do
create table(:posts, primary_key: false) do
add :id, :uuid, primary_key: true
add :body, :string
add :word_count, :integer
timestamps
@djk447
djk447 / Implementing an Array-Based Timeseries Store in Postgres.md
Last active October 26, 2022 16:42
Implementing an Array-Based Timeseries Store in Postgres

#Implementing an Array-Based Timeseries Store in Postgres

UPDATE: This is Part 1, Part 2 is here, enjoy!

In response to Jim Nasby's question over at ElephantStack I thought I'd play around with the concept and see where it took me. Hoping to spark ideas from others on how to store things that have a column and row element more effectively with Postgres. ##Data Setup The data I’m using for this example is publicly available data from the NYISO historical data set located here: http://www.nyiso.com/public/markets_operations/market_data/custom_report/index.jsp?report=rt_lbmp_gen

It’s the real time location based marginal price of electricity at multiple generators in New York State. The tables I’ve used to store data from the NYISO site are below (I probably ought be using text instea

module GraphQL
module Relay
module Cursor
# The encoder/decoder for the cursor used in our smart GraphQL connections
class DefaultEngine
def encode(data)
Base64.strict_encode64(JSON.generate(data))
end
def decode(cursor)
@pablobm
pablobm / README.md
Last active June 3, 2022 10:07
A clear convention for a CRUD with standard Ember + Ember Data

CRUD with Ember (+ Data)

Compatible with Ember 1.13.0+ Compatible with Ember Data 1.13.0+

Ember's official documentation describes a number of low-level APIs, but doesn't talk much about how to put them together. As a result, a simple task such as creating a simple CRUD application is not obvious to a newcomer.

@icholy
icholy / go_zsh_complete.md
Last active January 9, 2022 19:19
Zsh Tab Completion for Golang

Zsh Tab Completion for Golang

This is pretty specific to my setup but the idea can be adapted to work with pretty much anything.

Go has a flag package which makes parsing command line arguments really easy.

package main
@myobie
myobie / mountain-lion-brew-setup.markdown
Created February 18, 2012 20:14
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@vickeryj
vickeryj / role_based_authorization.rb
Created March 6, 2018 20:30
role based field authorization
GraphQL::Field.accepts_definitions(
required_role: GraphQL::Define.assign_metadata_key(:required_role),
unauthorized_value: GraphQL::Define.assign_metadata_key(:unauthorized_value)
)
class RoleBasedAuthorization
def instrument(_type, field)
if field.metadata[:required_role]
old_resolve_proc = field.resolve_proc
new_resolve_proc = ->(obj, args, ctx) do
@bgentry
bgentry / rated.go
Created October 11, 2012 23:48
Go token bucket rate limiter #golang
package main
import (
"fmt"
"time"
)
func main() {
ticker := rateLimit(4, 10)