Skip to content

Instantly share code, notes, and snippets.

View sikanhe's full-sized avatar
😈
demon time

Sikan He sikanhe

😈
demon time
View GitHub Profile
@sikanhe
sikanhe / doggies.json
Last active January 3, 2023 19:14
doggies
[
{
"id": 1,
"url": "https://images.dog.ceo/breeds/pointer-germanlonghair/hans2.jpg"
},
{
"id": 2,
"url": "https://images.dog.ceo/breeds/hound-english/n02089973_3480.jpg"
},
{
@sikanhe
sikanhe / table.tsx
Last active September 12, 2018 00:49
<Pagination
renderTableName{<b>Your Files</b>}
renderCallToAction={<BigButton>Upload</BigButton>}
totalPageCount={data.length / itemsPerPage}
>
{(pageNumber, reset) => (
<TableHead>
<Header onClick={this.sortByName(reset)}>Name</Header>
<Header onClick={this.sortByTitle(reset)}>Title</Header>
</TableHead>
defmodule Operations do
@moduledoc """
Examples:
operations Schema.Trip, :trip
operations Schema.User, :user, only: [:get, :delete]
# supports :plural option for list_x function
operations Schema.Datum, :datum, plural: :data
"""
defmacro operations(schema, name) do
{
id: "123",
store: {
name: "GAP",
id: "123"
},
name: "Winter Coat",
image_url: string,
sizes: ["small", "large"..],
color: ["green", "blue"]
defmodule RethinkDB.Response do
@moduledoc false
def parse(raw_data, token, pid) do
d = Poison.decode!(raw_data)
r = RethinkDB.Pseudotypes.convert_reql_pseudotypes(d["r"])
profile = d["p"]
type = d["t"]
resp = case type do
defmodule AWS.S3 do
import AWS.Utils
@config Application.get_env(:vino, __MODULE__)
@allowed_file_types ~w(.jpeg .jpg .png)
def base_url(bucket) do
"https://#{bucket}.s3.amazonaws.com/"
@sikanhe
sikanhe / textarea_autoheight.js
Last active May 16, 2023 04:28
Simple textarea that expand and shrinks depending on the content
import React, { PropTypes } from 'react'
export default class TextareaAutosize extends React.Component {
static propTypes = {
value: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
onChange: PropTypes.func
}
componentDidMount() {
defmodule MyApp.RethinkDB.Helpers do
def run(query, opts) do
query
|> MyApp.Database.run(opts)
|> handle_response
end
def run(query) do
run(query, [])
@sikanhe
sikanhe / rethinkdb_helpers.ex
Last active February 26, 2016 17:17
helpers for rethinkdb elixir
defmodule RethinkDB.Helpers do
def run(query) do
query
|> do_run
|> handle_response
end
def handle_response(%RethinkDB.Exception.ConnectionClosed{}) do
raise "Cannot connect to RethinkDB"
@sikanhe
sikanhe / rethinkdb-elixir-helpers.ex
Created February 12, 2016 05:17
rethinkdb-elixir helpers
defmodule App.Helpers do
use Timex
import App.Rethink, only: [run: 1]
alias RethinkDB.Query
def get(table, id) when is_bitstring(id) do
Query.table(table)
|> Query.get(id)