Skip to content

Instantly share code, notes, and snippets.

View efstathiosntonas's full-sized avatar

Stathis Ntonas efstathiosntonas

View GitHub Profile
@jsayol
jsayol / RNAsyncStorageAdapter.js
Last active February 25, 2021 13:47
An experimental React Native AsyncStorage wrapper for Firebase database persistence
import { AsyncStorage } from 'react-native';
const storeKey = (dbName, storeName, key) => dbName + '_' + storeName + '_' + key;
const stringify = JSON.stringify;
const parse = JSON.parse;
export const RNAsyncStorageAdapter = {
get(dbName, storeName, key) {
return AsyncStorage.getItem(storeKey(dbName, storeName, key)).then(value => parse(value));
},
@garrettmac
garrettmac / example.js
Last active January 14, 2022 19:11
react native congressmen floating bubble heads example
import React, { Component } from 'react';
import { StyleSheet, View,Text, Image, Animated, Dimensions } from 'react-native';
import Interactable from 'react-native-interactable';
const widthFactor = Dimensions.get('window').width / 375;
const heightFactor = (Dimensions.get('window').height - 75) / 667;
const showSecondFace = true;
const showThirdFace = true;
const showFourthFace = true;
@Ashoat
Ashoat / text-height-measurer.js
Created May 11, 2017 04:24
React Native component for measuring text height
// @flow
import type {
StyleObj,
} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
import React from 'react';
import PropTypes from 'prop-types';
import { Text, View, StyleSheet } from 'react-native';
import invariant from 'invariant';
@brennanMKE
brennanMKE / EventEmitter.swift
Last active July 15, 2025 09:06
React Native Event Emitter for RCTEventEmitter in Objective-C and Swift
class EventEmitter
/// Shared Instance.
public static var sharedInstance = EventEmitter()
// ReactNativeEventEmitter is instantiated by React Native with the bridge.
private static var eventEmitter: ReactNativeEventEmitter!
private init() {}
import { GoogleMapsAPIWrapper } from '@agm/core';
import { Directive, Output, EventEmitter } from '@angular/core';
declare var google: any;
@Directive({
selector: 'agm-location-marker'
})
export class AgmLocationMarker {
marker: any;
@vanpav
vanpav / http.js
Last active August 28, 2020 09:20
Small wrapper around Axios lib for post requests in Django
import Promise from 'promise-polyfill';
window.Promise = window.Promise || Promise;
import axios from 'axios';
import qs from 'qs';
const DJANGO_DEFAULTS = {
xsrfCookieName: 'csrftoken',
xsrfHeaderName: 'X-CSRFToken',
headers: {
@sdgluck
sdgluck / query.js
Last active April 23, 2024 17:48
Pagination using Mongo: populate, match, sort, count, and limit with the aggregation pipeline
/**
* Query blog posts by user -> paginated results and a total count.
* @param userId {ObjectId} ID of user to retrieve blog posts for
* @param startRow {Number} First row to return in results
* @param endRow {Number} Last row to return in results
* @param [filter] {Object} Optional extra matching query object
* @param [sort] {Object} Optional sort query object
* @returns {Object} Object -> `{ rows, count }`
*/
function queryBlogPostsByUser (userId, startRow, endRow, filter = {}, sort = false) {
@glenngr
glenngr / example-usage.ts
Last active December 17, 2018 23:50
Fit contents directive for angular2-google-maps (sebm-google-map)
import { Subject } from 'rxjs/Subject';
import { Store } from '@ngrx/store';
import { Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
import { AppState } from '../../../root.reducer';
@Component({
selector: 'my-map-example',
template: `
<sebm-google-map
@radiovisual
radiovisual / .eslintrc
Last active October 30, 2021 11:55
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
@vazad28
vazad28 / img-zoom.html
Last active September 30, 2024 18:26
Page code for image pinch and zoom in ionic RC3. I used code from multiple places and credit is due. I cant seem to find the pages I have used the code from. If you know, please tell me so I can add that here.
<ion-header no-shadow>
<ion-navbar no-border-bottom>
<ion-buttons start>
<button ion-button color="light" (click)="closeModal()">Cancel</button>
</ion-buttons>
<ion-title>Media</ion-title>
<ion-buttons end>
<ion-spinner *ngIf="!mediaLoaded" color="light"></ion-spinner>
</ion-buttons>