Skip to content

Instantly share code, notes, and snippets.

View falcon11's full-sized avatar
🌏
🐳

Ashoka falcon11

🌏
🐳
View GitHub Profile
@falcon11
falcon11 / ios_detect.swift
Created April 20, 2018 16:15 — forked from mahmudahsan/ios_detect.swift
iPhone X and other iOS device detection by Swift and Objective-C
struct Device {
// iDevice detection code
static let IS_IPAD = UIDevice.current.userInterfaceIdiom == .pad
static let IS_IPHONE = UIDevice.current.userInterfaceIdiom == .phone
static let IS_RETINA = UIScreen.main.scale >= 2.0
static let SCREEN_WIDTH = Int(UIScreen.main.bounds.size.width)
static let SCREEN_HEIGHT = Int(UIScreen.main.bounds.size.height)
static let SCREEN_MAX_LENGTH = Int( max(SCREEN_WIDTH, SCREEN_HEIGHT) )
static let SCREEN_MIN_LENGTH = Int( min(SCREEN_WIDTH, SCREEN_HEIGHT) )
@falcon11
falcon11 / react-native-pinch-zoom.js
Created May 18, 2018 04:47 — forked from zshell31/react-native-pinch-zoom.js
React Native: how to implement pinch to zoom gesture
/** Links:
* - http://stackoverflow.com/questions/36368919/scrollable-image-with-pinch-to-zoom
* - http://blog.lum.pe/gesture-detection-in-react-native-fixing-unexpected-panning/
*
*/
import React, {Component, PropTypes} from 'react';
import { Text, View, PanResponder, Image } from 'react-native';
function calcDistance(x1, y1, x2, y2) {
@falcon11
falcon11 / README.md
Last active October 29, 2024 14:40
A react native year month picker.

react-native-year-month-picker

A year month picker component for react native.

Usage

import yearMonthPicker.js file to your project.
detail usage you can check for the example.js file.
or open this snap in expo

@falcon11
falcon11 / topview.js
Created September 12, 2018 01:09 — forked from mactive/topview.js
rn-topview
/**
* [email protected]
* 2017-05-08
*/
'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@falcon11
falcon11 / jquery-scroll-bottom.js
Created February 26, 2019 09:48 — forked from toshimaru/jquery-scroll-bottom.js
Detect the scrolling to bottom of the page using jQuery.
$(window).on("scroll", function() {
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
// when scroll to bottom of the page
}
});
@falcon11
falcon11 / generate-ipa.sh
Created June 28, 2019 13:02
auto generate ipa
#!/bin/bash
BuidPath=build/`date +%F-%T`
ProjectName=HNPositionAsst
Configuration=Release
ExportOptionsPlist=ExportOptions.plist
IPA_NAME=app
mkdir -p $BuidPath
archivePath=$BuidPath/$ProjectName.xcarchive
@falcon11
falcon11 / AES_GCM.m
Created November 9, 2020 02:31
Objective-C AES/GCM/NoPadding crypto
// pod 'AesGcm'
#import <AesGcm/IAGAesGcm.h>
// replace with your own key, base64 encoding
static NSString * const AES_GCM_KEY = @"MTIzNDU2Nzg5MGFiY2RlZg==";
- (NSString *)encryptString:(NSString *)text {
NSData *key = [[NSData alloc] initWithBase64EncodedString:AES_GCM_KEY options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSData *iv = [self randomKeyDataGeneratorWithNumberBits:96];
@falcon11
falcon11 / AES_GCM.js
Created November 12, 2020 10:11
AES_GCM crypto
const base64Key = 'your key base64 encode';
let secretKey;
function getKeyArray(key) {
const bkey = atob(key);
const keyArray = [];
for (let i = 0; i < bkey.length; i += 1) {
keyArray.push(bkey.charCodeAt(i));
}
return keyArray;
@falcon11
falcon11 / Podfile-remove-static-dependencies.ruby
Last active November 17, 2020 07:50
Cocoapods Podfile remove subproject's static library and static framework from other linker flag
post_install do |installer|
# main project pod target
applicationTargets = [
'Pods-Mall',
]
embedded_targets = installer.aggregate_targets.select { |aggregate_target|
!(applicationTargets.include? aggregate_target.name)
}
@falcon11
falcon11 / react-dynamic-import.md
Created May 9, 2021 05:36 — forked from adyontech/react-dynamic-import.md
A simple trick to dynamically import components in react.

AsyncLoadFile.jsx

import React, { Component } from 'react';

export default function asyncComponent(importComponent) {
    class AsyncComponent extends Component {
        /**
        * @constructor
        * @desc Represents AsyncComponent component
        * @param props Properties passed from parent component