Skip to content

Instantly share code, notes, and snippets.

View churcho's full-sized avatar

Churchill Aboge churcho

  • Nairobi/Kenya
View GitHub Profile
@churcho
churcho / gist:220ff5ce345dbff72ca0b13c1cda3efb
Created April 28, 2017 21:21 — forked from sdebnath/gist:36c235e042cb35db7d1f
Add field to Riak YZ Schema with CRDTs
This gist captures what needs to be done to add a new field to Riak's Yokozuna
search index.
Sources:
- https://github.com/basho/yokozuna/issues/130
- http://riak-users.197444.n3.nabble.com/How-to-update-existed-schema-td4032143.html
The code below is for illustration purposes only. Use at your own risk.
1. Create/Update new schema file
@churcho
churcho / ArtistList.js
Created September 5, 2017 17:23 — forked from n1ru4l/ArtistList.js
mobx + apollo-client + react
import React from 'react'
import { observer } from 'mobx-react'
function ArtistList({ uiState: { artistData } }) {
const { data } = artistData;
if ( !data || !data.artists || !data.artists.length ) {
return <div>No artists bruh.</div>
}
const { artists } = data
return (
@churcho
churcho / .gitignore
Created September 13, 2017 15:01 — forked from ksauzz/.gitignore
Riak multi node setup script for single host.
nodes
export const isObjectEqual = (obj1, obj2) => {
if(!isObject(obj1) || !isObject(obj2)) {
return false;
}
// are the references the same?
if (obj1 === obj2) {
return true;
}
@churcho
churcho / phoenix_read_more_helper_snippet.ex
Created March 16, 2018 17:58 — forked from BillBarnhill/phoenix_read_more_helper_snippet.ex
Example of a Phoenix view helper (put in your view or in App views) that inserts a read more link
@doc """
Inserts a link to the show path of a resource item. The
item must implement .id.
##Example
<%= read_more_link @conn, @post %>
"""
def read_more_link(conn, item) do
@churcho
churcho / antd_sc_example.js
Created July 5, 2018 12:33 — forked from newswim/antd_sc_example.js
Wrapping Ant Design components with Styled Components
import { Link } from 'react-router-dom'
import { Badge, Col, Menu } from 'antd'
const StyledBadge = styled(Badge)`
.ant-badge-count {
background-color: #7ECBBF;
color: white;
box-shadow: 0 0 0 1px #d9d9d9 inset;
}
`
#!/bin/bash
# Maintainer Joel Jacobson
VERSION="5.0.0"
# to start the services you must be root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
@churcho
churcho / Map.Helpers
Created July 19, 2018 14:27 — forked from kipcole9/Map.Helpers
Helpers for Elixir Maps: underscore, atomise and stringify map keys
defmodule Map.Helpers do
@moduledoc """
Functions to transform maps
"""
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
@churcho
churcho / colors.source
Created July 20, 2018 20:38 — forked from leesei/colors.source
#bash #color-source Color macro for BASH
# prompt color and format variables
# A color init string consists of one or more of the following numeric codes:
# * Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# * Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# * Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
# * Extended color codes for terminals that support more than 16 colors:
@churcho
churcho / model_user.ex
Created November 10, 2018 10:02 — forked from kiennt/model_user.ex
Absinthe authorization example
defimpl Kipatest.Can, for: Kipatest.User do
use Kipatest.Web, :model
def can?(%User{} = subject, :owner, %User{} = user) do
user.id == subject.id
end
end