Skip to content

Instantly share code, notes, and snippets.

Alex Dunae alexdunae

View GitHub Profile
View effect.js
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
const EventSalesReport = props => {
const [open, setOpen] = useState(false);
const [count, setCount] = useState(0);
console.log(`render: open is ${open}`);
const handleDocumentClick = function(event) {
@alexdunae
alexdunae / ReactNativeJson.java
Last active May 13, 2018 — forked from viperwarp/ReactNativeJson.java
React-Native Module, ReadableMap/Array to Java JSON objects
View ReactNativeJson.java
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
View salmon.php
<?php
add_action( 'rest_api_init', function () {
register_rest_route( 'salmon/v1', '/salmonnames', array(
'methods' => 'GET',
'callback' => 'get_salmon_names',
) );
} );
View redis.conf
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
View allocate.rb
# from https://github.com/drKreso/guerrilla_patch
class Allocate
attr_accessor :amount
attr_accessor :ratios
def self.evenly(amount, number_of_slices)
Allocate.new.tap do |a|
a.amount = amount
a.ratios = (1..number_of_slices).map { 1.to_d/number_of_slices }
end.divided
View matt.rb
cw = ChatWindow.new(user, other_user)
cw.avatar
cw.lasst_update
cw.messages.each do |m|
render m
end
cw.last_updated
@alexdunae
alexdunae / Gemfile
Created Apr 15, 2015
prawn-for-mike
View Gemfile
# in your Gemfile
gem 'prawn'
gem 'prawn-table'
# then run bundle install
View kerene.rb
# goes to PagesController, home action
root 'pages#home'
class CharacterImporter
def initialize(character)
@character = character
View raph.rb
# /waiters/tables_calling.json
# in the controller
#
# you want an array of table IDs as the output
def tables_calling
calling = []
@tables.where(calling: true).each do |table|
calling << table.id
end
You can’t perform that action at this time.