Skip to content

Instantly share code, notes, and snippets.

View Arjun-sna's full-sized avatar
🚧
!

Arjun Arjun-sna

🚧
!
View GitHub Profile
{
"scripts": {
// ... other scripts
"dev-build-android-staging": "ENVFILE=.env.staging react-native run-android",
"dev-build-android-prod": "ENVFILE=.env.prod react-native run-android",
"release-build-android-prod": "export ENVFILE=.env.prod && cd android && ./gradlew assembleRelease && cd ..",
"release-build-android-staging": "export ENVFILE=.env.staging && cd android && ./gradlew assembleRelease && cd ..",
"start-staging-server": "ENVFILE=.env.staging react-native start",
"start-prod-server": "ENVFILE=.env.prod react-native start",
}
public ReactNativeHost getCodePushKey() {
return BuildConfig.CODEPUSH_ANDROID_KEY;
}
import Config from 'react-native-config';
import axios from 'axios';
const response = await axios(GITHUB_OAUTH_ENDPOINT, {
method: METHOD.POST,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
data: JSON.stringify({
CLIENT_ID=982****
CLIENT_SECRET=bd51f3***
CODEPUSH_ANDROID_KEY=KAZeMD7***
CODEPUSH_IOS_KEY=KVFoIZBiA****
CLIENT_ID=982****
CLIENT_SECRET=bd51f3***
CODEPUSH_ANDROID_KEY=KAZeMD7***
CODEPUSH_IOS_KEY=KVFoIZBiA****
@Arjun-sna
Arjun-sna / createReducer.js
Last active June 24, 2018 06:25
Gist to create reducer in redux
export function createReducer(reducerMap, defaultState) {
return (state = { ...defaultState }, action) => reducerMap.hasOwnProperty(action.type) ? reducerMap[action.type](state, action) : state;
}
// Sample usage
posts: createReducer({
[ALL_POSTS_RECEIVED]: (state, action) => {
//do something
},
[POSTS_REQUEST_IN_PROGRESS]: (state, action) => {
@Arjun-sna
Arjun-sna / Previewsize.java
Last active January 12, 2024 09:41
Get best preview size for android camera
private static final double MAX_ASPECT_DISTORTION = 0.15;
private static final float ASPECT_RATIO_TOLERANCE = 0.01f;
//desiredWidth and desiredHeight can be the screen size of mobile device
private static SizePair generateValidPreviewSize(Camera camera, int desiredWidth,
int desiredHeight) {
Camera.Parameters parameters = camera.getParameters();
double screenAspectRatio = desiredWidth / (double) desiredHeight;
List<Camera.Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes();
List<Camera.Size> supportedPictureSizes = parameters.getSupportedPictureSizes();
@Arjun-sna
Arjun-sna / TypeFaceEditText.java
Created February 21, 2017 11:57
Workaround for android `Softkeyboard` hiding `Edittext` and with custom `TypeFace`
public class TypeFaceEditText extends EditText {
static Map<String, Typeface> inflatedFonts = new HashMap<>();
public TypeFaceEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs);
}
public TypeFaceEditText(Context context, AttributeSet attrs) {
super(context, attrs);
@Arjun-sna
Arjun-sna / SettingsWithSwitch.java
Last active June 23, 2018 04:30
Switch with TextView using merge layout
public class SettingWithSwitch extends RelativeLayout {
TextView settingTitle;
TextView settingState;
SwitchCompat toggleSwitch;
public SettingWithSwitch(Context context) {
super(context);
init(context, null, 0, 0);
}