Skip to content

Instantly share code, notes, and snippets.

View davidyaha's full-sized avatar

David Yahalomi davidyaha

View GitHub Profile
{
"event_id": "01EJREWM6FP77YF2NZY34C5216",
"event_type": "form_response",
"form_response": {
"form_id": "dvWylptA",
"landed_at": "2020-09-21T13:50:42Z",
"submitted_at": "2020-09-21T13:50:42Z",
"answers": [
{
"type": "text",
@davidyaha
davidyaha / fetch-with-progress.ts
Created January 15, 2019 15:09
Fetch-like API that returns an Rx observable so that you can watch for progress. Created for uploading files.
import { Observable } from 'rxjs';
export function fetchWithProgress(
url: string,
opts: RequestInit = {},
): Observable<ProgressEvent | Response> {
return new Observable(observer => {
const xhr = new XMLHttpRequest();
xhr.open(opts.method || 'get', url, true);
@davidyaha
davidyaha / expo-ts-svgr-template.js
Last active December 26, 2018 13:21
Expo TS svgr template. To run, add the template file to your project and run `npx @svgr/cli --native --template ./expo-svgr-template.js ./path-to-svg.svg`
function template({ template }, opts, { imports, componentName, props, jsx, exports }) {
const typeScriptTpl = template.smart({ plugins: ['typescript'] });
return typeScriptTpl.ast`
import { Svg } from 'expo';
import * as React from 'react';
const {
Circle,
ClipPath,
Defs,
@davidyaha
davidyaha / mongo-connector.ts
Created January 3, 2018 11:30
Reconnecting MongoDB driver v3.0 for node.js using RxJS
import { MongoClient, Db } from 'mongodb';
import { Observable } from 'rxjs';
import { config } from '../core/config';
import { logger } from '../core/logger';
const urlFromConfig = config.mongo.url;
export const mongoConnector = (mongoUrl?: string) => {
const connection = new Observable<Db>(observer => {
logger.info('Trying to connect to mongo');
@davidyaha
davidyaha / auto_semver.sh
Created July 11, 2015 18:49
This script is used for auto calculate the next semver based on the current commit badge. e.g.: '(Major) Released my best version ever'. The script will take the words in the parenthesis and will act accordingly.
#!/bin/sh
#######################################################################
# version.sh - #
# This script will check for the latest commit badge #
# and will return a version numeber that corresponds #
# to the semver spec. #
# Latest commit tag should have '(patch)', '(minor)' or '(major) #
# in the comment. The script is not case sensitive. #
# Other badges will be interpreted as patch version #
# #