Skip to content

Instantly share code, notes, and snippets.

View danielkcz's full-sized avatar
🏗️
Building own experimental dating app

Daniel K. danielkcz

🏗️
Building own experimental dating app
View GitHub Profile
@danielkcz
danielkcz / primes.coffee
Created August 4, 2014 14:35
Getting prime numbers
primes = []
findNextPrime = ->
len = primes.length
pr = primes[len - 1] or 1
loop
pr += if len > 2 then 2 else 1
divides = false
i = 0
# discard the number if it divides by one earlier prime.
@danielkcz
danielkcz / EventEmittable.js
Last active June 18, 2016 03:40
Simple example of use of the stampit library to create easy to define models with getters/setters and true private values.
import stampit from 'stampit';
import EventEmitter from 'events';
const EventEmittable = stampit({
initializers: function initEventEmitter() {
Reflect.apply(EventEmitter, this, []);
},
methods: ['emit', 'on', 'once', 'removeListener'].reduce((methods, methodName) => {
methods[methodName] = EventEmitter.prototype[methodName];
return methods;
Arguments:
C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\yarn\bin\yarn.js add blackdice/errorception
PATH:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\users\DarkMaster\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft\Web Platform Installer\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;%NVM_HOME%;%NVM_SYMLINK%;C:\Program Files\Git\cmd;D:\users\DarkMaster\AppData\Local\Programs\Git\cmd;D:\users\DarkMaster\AppData\Local\Microsoft\WindowsApps;D:\users\DarkMaster\AppData\Roaming\nvm;C:\Program Files\nodejs
Yarn version:
0.17.0
Node version:
@danielkcz
danielkcz / package.json
Last active November 30, 2016 14:53
Yarn install size difference
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"async": "0.9.0",
"babel-core": "6.18.0",
"babel-plugin-react-require": "3.0.0",
"babel-preset-es2015": "6.18.0",
@danielkcz
danielkcz / firebase.functions.js
Last active January 11, 2019 12:40
Firebase authentication with Graphcool
const functions = require('firebase-functions')
const admin = require('firebase-admin')
// This is hosted using Firebase Functions to gain easier access without meddling with service key
admin.initializeApp(functions.config().firebase)
exports.verifyToken = functions.https.onRequest((req, res) => {
const { idToken } = req.query
if (!idToken) {
@danielkcz
danielkcz / App.js
Created September 6, 2017 12:59
Update Expo app
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Util } from 'expo'
export default class App extends React.Component {
state = {
updated: false,
}
componentWillMount() {
Util.addNewVersionListenerExperimental(() => {
@danielkcz
danielkcz / TimingModel.ts
Created February 21, 2018 10:15
Timing with MST
import { types } from 'mobx-state-tree'
const SECOND = 1 * 1000
const MINUTE = 60 * SECOND
export const TimingModel = types
.model('Timing', {
bySecond: types.optional(types.number, Infinity),
byMinute: types.optional(types.number, Infinity),
autoStart: false,
@danielkcz
danielkcz / mobx-react-form.d.ts
Created March 1, 2018 08:49
Crude typescript defintion for MRF
declare module 'mobx-react-form' {
export default MRF.MobxReactForm
}
type Dictionary<T> = { [key: string]: T }
declare namespace MRF {
class MobxReactForm {
constructor(options: MRF.Options, settings?: MRF.Settings)
isValid: boolean
@danielkcz
danielkcz / buildMutation.ts
Last active March 7, 2018 13:25
Apollo GraphQL with render props
import { ApolloQueryResult } from 'apollo-client'
import { DocumentNode } from 'graphql'
import React from 'react'
import { graphql } from 'react-apollo'
import { MutationFunc, MutationOpts } from 'react-apollo/types'
interface IQueryProps<TResult, TVariables = {}> {
render(
execute: (variables?: Partial<TVariables>) => Promise<TResult>,
executionOptions?: MutationOpts<TVariables>,
import { Trans } from '@lingui/react'
import React, { Children } from 'react'
interface IProps {
children: ReactNode | string
}
interface IState {
refs: React.RefObject<Trans>[]