Skip to content

Instantly share code, notes, and snippets.

View eric-burel's full-sized avatar
Writing agentic AI professional trainings

Eric Burel eric-burel

Writing agentic AI professional trainings
View GitHub Profile
@eric-burel
eric-burel / nextConfigPackageVersion.js
Created February 26, 2021 08:09
next config public app
// in next.config.js
import packageJson from "./package.json"
module.exports = {
env: {
NEXT_PUBLIC_APP_VERSION: packageJson.version
}
}
import snakeCase from 'lodash/snakeCase';
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import fs from 'fs';
let bound;
if (Meteor.isServer) {
bound = Meteor.bindEnvironment(callback => callback());
}
// Package 1 - "my-basic-ui"
const MyBasicButton = ({onClick, children}) => (
<button onClick={onClick}>
{children}
</button>
)
// Tell other packages they can use your component
// under the name "Button"
registerComponent({
name: 'Button',
VendingMachines.addField([
{
fieldName: 'lastRefillAt',
fieldSchema: {
type: Date,
optional: true,
viewableBy:['runners', 'managers', 'admins'],
resolveAs: {
type: 'Date',
resolver(vendingMachine, args, context) {
class MyService {
constructor(options) {
// options must contain the knexClient
// (simply pass it when initializing the service)
this.options = options || {};
}
async find(params){
const { db } = this.options
const q = db.raw(`SELECT * FROM TABLE`)
// my-service.hooks.js
module.exports = {
before:{
find:[
async findQuery(context){
// get the client (Express global)
const { db } = context.app.get('knexClient')
// build and run the query
const q = db.raw(`SELECT * FROM TABLE`)
const res = await q
@eric-burel
eric-burel / geeglee-redux-nested.jsx
Created April 16, 2018 20:03
geeglee-redux-nested
<ObjectElement keyPath="user" onChange={doChange}>
<div>
<StringInput keyPath="name"/>
</div>
</ObjectElement>
@eric-burel
eric-burel / geeglee-redux-form.jsx
Created April 16, 2018 20:02
geeglee-redux-form
<ArrayElement keyPath="subsets" onChange={updateReduxState}>
<ObjectElement wrapper>
<StringInput keyPath="name"/>
<QueryInput keyPath="column" options={availableColumns}/>
<StringInput keyPath="value" />
<ColorInput keyPath="color" />
</ObjectElement>
<ArrayElement/>
@eric-burel
eric-burel / geeglee-redux-lowdb.js
Created April 16, 2018 19:57
geeglee-redux-lowdb
const lodashId = require('lodash-id')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('db.json')
const db = low(adapter)
db._.mixin(lodashId)
// We need to set some default values, if the collection does not exist yet
// We also can store our collection
@eric-burel
eric-burel / geeglee-dataviz-rpc.js
Created April 14, 2018 09:48
geeglee-dataviz-rpc
rpcServer.invoke('fastFilter', 'my-filter-id', { "range": [10,20] }, (err, done) => {
// handle response or error
});