Skip to content

Instantly share code, notes, and snippets.

View simform-solutions's full-sized avatar

Simform simform-solutions

View GitHub Profile
/**
* get the date format by using the date as a string.
* This Extension function returns date format, if it matches with any format else it will return null
*/
fun String.getDateFormat(): String? {
val dateFormats = arrayOf(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
"yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"yyyy-MM-dd'T'HH:mm:ss'Z'",
@simform-solutions
simform-solutions / iota_python.py
Last active May 28, 2019 15:41
Proof of work on python based IOTA implementation. Python 2.7 (not compatible yet with python 3) and the PyOTA library ***pip install pyota***
import getpass
import hashlib
import json
import time
import datetime
import re
import os
import RPi.GPIO as GPIO
from operator import itemgetter
@simform-solutions
simform-solutions / RetrofitException.java
Last active May 21, 2019 20:36
RxErrorHandlingCallAdaptorFactory+RxJava2 global retrofit error handler.
import com.google.gson.stream.MalformedJsonException;
import java.io.IOException;
import java.lang.annotation.Annotation;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response;
import retrofit2.Retrofit;
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
if let imageAnchor = anchor as? ARImageAnchor {
let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
plane.firstMaterial?.diffuse.contents = UIColor(white: 1, alpha: 0.8)
let material = SCNMaterial()
material.diffuse.contents = viewObj
plane.materials = [material]
let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = -.pi / 2
@simform-solutions
simform-solutions / DataTabe.js
Created June 20, 2018 11:19
Material DataTable component with Dynamic data and Event Handlers
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import TablePagination from '@material-ui/core/TablePagination';
import TableRow from '@material-ui/core/TableRow';
@simform-solutions
simform-solutions / Login.component.js
Created June 20, 2018 11:01
Auth module with Redux and Saga Integration
import React, { Fragment } from 'react'
import cx from 'classnames'
import { connect } from 'react-redux'
import { Icon } from 'antd'
import { Helmet } from 'react-helmet'
import { FormattedMessage } from 'react-intl'
import { withRouter } from 'react-router-dom'
import { truncatePhoneNumber } from 'config/utils'
import { required, phoneConstraints } from 'config/validators'
import { actions } from 'rdx/auth'
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode?
let configuration = ARWorldTrackingConfiguration()
// ARReferenceObject(archiveURL :... this method used when we have ARReferenceObject Store in local Document Directory
configuration.detectionObjects = Set([try ARReferenceObject(archiveURL: objectURL!)])
// ARReferenceObject.referenceObjects(inGroupNamed... this method used when we have ARReferenceObject Store in Assest Folder
configuration.detectionObjects = ARReferenceObject.referenceObjects(inGroupNamed: "", bundle: .main)!
sceneView.session.run(configuration)
func receivedData(_ data: Data, from peer: MCPeerID) {
if let unarchived = try? NSKeyedUnarchiver.unarchivedObject(of: ARWorldMap.classForKeyedArchiver()!, from: data), let worldMap = unarchived as? ARWorldMap {
// Run the session with the received world map.
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .horizontal
configuration.initialWorldMap = worldMap
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
mapProvider = peer
}
}
sceneView.session.getCurrentWorldMap { worldMap, error in
guard let map = worldMap
else { print("Error: \(error!.localizedDescription)"); return }
guard let data = try? NSKeyedArchiver.archivedData(withRootObject: map, requiringSecureCoding: true)
else { fatalError("can't encode map") }
self.multipeerSession.sendToAllPeers(data)
}