Skip to content

Instantly share code, notes, and snippets.

View fakenickels's full-sized avatar
💭
hello this is a mic test, are you listening

Gabriel fakenickels

💭
hello this is a mic test, are you listening
View GitHub Profile
"ocaml": {
"command": "esy",
"args": ["exec-command", "--include-current-env", "ocamlmerlin-lsp"],
"rootPatterns": ["esy.json", "package.json"],
"filetypes": ["ocaml", "reason"]
}
module SafeList = {
type empty =
| Empty;
type nonEmpty =
| NonEmpty;
type t('a, 's) =
| []: t('a, empty)
| ::(('a, t('a, 's))): t('a, nonEmpty);
let rec length: type s. t(_, s) => int =
fun
import 'isomorphic-fetch'
import cheerio from 'cheerio'
import moment from 'moment-timezone'
import BigNumber from 'bignumber.js'
export const crawlSELIC = async () => {
const page = await fetch(
'http://idg.receita.fazenda.gov.br/orientacao/tributaria/pagamentos-e-parcelamentos/taxa-de-juros-selic',
)
files=$(ls src/**/*.re)
# Make them functors
for file in $files; do
sed -i '' -e '1s/^/module Make = (AppConfig: AppConfigTypes.AppConfig) => { /' $file
echo "\n}" >> $file
done
# Forward functor to other functors
for file in $files; do
/* actually there is a way to do this with reduce + find but would be really expensive if there are too many elements */
/* Really don't bother with all these now, it's just some optimizations you can do with BuckleScript */
let groupBy = (type a, items, ~key) => {
let cmp: (a, a) => int = Pervasives.compare;
module Cmp = (val Belt.Id.comparable(~cmp));
let empty = Belt.Map.make(~id=(module Cmp));
let merge = newItem =>
fun
| None => Some([newItem])
| Some(existingItems) => Some([newItem, ...existingItems]);
@fakenickels
fakenickels / server.js
Last active May 18, 2019 16:05
Node.REACT: wait that's illegal
const Worker = ({ databaseURL, store }) => {
return (
<>
<Job name='chargeUsers' run={() => chargeUsers()} store={store}>
<SyncedCron at='every day at 8am' />
</Job>
<Job name='sendEmail' run={sendgridSendEmail} store={store} />
</>
);
};
@fakenickels
fakenickels / metro.config.js
Last active December 22, 2019 04:54 — forked from sibelius/metro.config.js
metro config to work with yarn workspaces
const path = require('path');
const getWorkspaces = require('get-yarn-workspaces');
const blacklist = require('metro-config/src/defaults/blacklist');
const workspaces = getWorkspaces(__dirname);
// Blacklists any react-native that doesn't come from packages/app
const blacklistRE = blacklist([ /(?<!packages\/app\/)node_modules\/react-native\/.*/g])
// @flow
import { ConnectionHandler } from 'relay-runtime';
import { isObject, isArray } from 'lodash/fp';
export function listRecordRemoveUpdater({ parentId, itemId, parentFieldName, store }) {
const parentProxy = store.get(parentId);
const items = parentProxy.getLinkedRecords(parentFieldName);
parentProxy.setLinkedRecords(items.filter(record => record._dataID !== itemId), parentFieldName);
}

try on curl to see curl
-X POST
-H "Content-Type: application/json"
--data '{ "query": "query { users { id, role } } " }'
http://localhost:3000/graphql

the most awesome thing about plyaing with graphql and ocaml is because they are really idiomatic together

" ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
let s:opam_share_dir = system("opam config var share")
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
let s:opam_configuration = {}
function! OpamConfOcpIndent()
execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
endfunction
let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')