Skip to content

Instantly share code, notes, and snippets.

View tlvenn's full-sized avatar

Christian Meunier tlvenn

View GitHub Profile
// This file allows us to inspect the traffic going over the Native <-> JS bridge, and can be
// helpful for debugging. Setting this to true should never be committed to git
const ENABLE_BRIDGE_DEBUGGER = false; // <-- THIS SHOULD NOT BE TRUE IN MASTER!!!!
// if true, function arguments will get pretty printed
const PRETTY_PRINT = false;
// enable this if you want to ignore EVERY event, except for the ones that match the `FOCUSED_*`
// constants. If true, you configure what you want to see. If false, you configure what you DONT
// want to see.
defmodule Absinthe.Ecto.Resolution.Schema do
@moduledoc """
This module provides helper functions to resolve a GraphQL query into `Ecto.Query`.
"""
import Absinthe.Resolution.Helpers
import Ecto.Query
alias Absinthe.Resolution
alias Absinthe.Blueprint.Document.Field
@tlvenn
tlvenn / README.md
Created October 29, 2016 10:42 — forked from rbishop/README.md
A super simple Elixir server for sending Server Sent Events to the browser.

Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:

  defp deps do
    [
      {:cowboy, "~> 1.0.0"},
      {:plug, "~> 0.8.1"}
    ]
  end
def index(conn, %{"event" => "true"}) do
conn = conn
|> put_resp_content_type("text/event-stream")
|> send_chunked(200)
{:ok, conn} = chunk(conn, ["data: ", JSON.encode!(Thermostat.Data.get()), "\n\n"])
Phoenix.Topic.subscribe self, "data"
data_updated(conn)
end
defp data_updated(conn) do
@tlvenn
tlvenn / component.js
Created June 22, 2016 12:36 — forked from capaj/component.js
react stateful function component
import React from 'react'
import {observer} from 'mobx-react'
import {observable} from 'mobx'
const state = observable({
value: 0
})
const Comp = (props) => {
return <div onClick={() => state.value++}>click to increase counter value: {state.value}</div>
@tlvenn
tlvenn / letsencrypt-jetty.sh
Created June 1, 2016 14:45 — forked from xkr47/letsencrypt-jetty.sh
How to use Letsencrypt certificate & private key with Jetty
# input: fullchain.pem and privkey.pem as generated by the "letsencrypt-auto" script when run with
# the "auth" aka "certonly" subcommand
# convert certificate chain + private key to the PKCS#12 file format
openssl pkcs12 -export -out keystore.pkcs12 -in fullchain.pem -inkey privkey.pem
# convert PKCS#12 file into Java keystore format
keytool -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks
# don't need the PKCS#12 file anymore
@tlvenn
tlvenn / mobxLogger.js
Created May 31, 2016 01:05 — forked from mmazzarolo/mobxLogger.js
While waiting for React-Native MobX devtools...
import mobx from 'mobx'
const DEFAULT_STYLE = 'color: #006d92; font-weight:bold;'
// Just call this function after MobX initialization
// As argument you can pass an object with:
// - collapsed: true -> shows the log collapsed
// - style -> the style applied to the action description
export const startLogging = ({ collapsed, style } = {}) => {
mobx.spy(event => {
@tlvenn
tlvenn / _readme.md
Created May 24, 2016 13:09 — forked from dboskovic/_readme.md
KeystoneJS: Cloudinary Cache => Amazon S3

I had a client who I built a site for (ecommerce) that had a lot of high resolution images. (running about 500gb/mo). Cloudinary charges $500/mo for this usage and Amazon charges about $40. I wrote some middleware that I used to wrap my cloudinary urls with in order to enable caching. This is entirely transparent and still enables you to use all the cool cloudinary effect and resizing functions. Hopefully this is useful to someone!

I think using deasync() here is janky but I couldn't think of another way to do it that allowed for quite as easy a fix.

@tlvenn
tlvenn / get_random_bytes.js
Created May 5, 2016 06:32 — forked from alexdiliberto/get_random_bytes.js
Get random bytes in Javascript (Browser/Node)
let getRandomBytes = (
(typeof self !== 'undefined' && (self.crypto || self.msCrypto))
? function() { // Browsers
var crypto = (self.crypto || self.msCrypto), QUOTA = 65536;
return function(n) {
var a = new Uint8Array(n);
for (var i = 0; i < n; i += QUOTA) {
crypto.getRandomValues(a.subarray(i, i + Math.min(n - i, QUOTA)));
}
return a;
@tlvenn
tlvenn / gist:bce2f06f8bdc7e6c1d6521c7e6cfa138
Created May 3, 2016 15:15 — forked from mattconnolly/gist:7804176
Upgrading pkgin repository for a SmartOS zone.

Upgrading SmartOS zone

Make a snapshot first! Upgrading from 2013Q1 to 2013Q3 because I needed newer nginx.

Update pkgin repository

edit the files at:

/opt/local/etc/pkg_install.conf

/opt/local/etc/pkgin/repositories.conf