Skip to content

Instantly share code, notes, and snippets.

View benvium's full-sized avatar

Ben Clayton benvium

  • www.calvium.com
  • Bristol, UK
View GitHub Profile
@benvium
benvium / androidWifiDebug.sh
Last active April 4, 2016 16:32
Android: Set up WiFi Debugging
# Connect Android Device via USB cable
# Type in terminal
adb tcpip 5555
# > restarting in TCP mode port: 5555
# Find android device's IP with (Settings/About/Status)
adb connect X.X.X.X
@benvium
benvium / react-native-navigator-ios-right-button.jsx
Created March 30, 2016 09:18
React Native NavigatorIOS - how to use onRightButtonPress to call a component method
const MyComponent = React.createClass({
statics: {
getRoute: function (props:Object) {
// To pass in the onLeft/RightButton press
// to out instance we need to use the 'ref'
// function (in passProps).
// This'll be passed the component instance, that we can call the methods on.. Phew!
let instance = null;
const route = {
@benvium
benvium / react-native-keyboard-show-resize.js
Last active October 15, 2020 04:06
React Native. Resize a view when the keyboard appears or hides.
'use strict';
const React = require('react-native');
const {
DeviceEventEmitter,
LayoutAnimation,
Dimensions,
} = React;
@benvium
benvium / react-native-parse-xml-example.js
Last active June 4, 2020 05:22
Parse XML Example using React Native.xmldom is a pure JavaScript implementation of an XML Parser. I've added it to window so that browser modules that require it will work. Tested on iOS and Android.
/**
*
* Before use, type:
* ```
* npm install xmldom --save
* ```
*/
window.DOMParser = require('xmldom').DOMParser;
@benvium
benvium / react-native-ios-splash.m
Created February 23, 2016 10:00
React Native iOS Smooth Splash Screen (when using LaunchScreen.xib)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
...
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MyAwesomeApp"
initialProperties:@{}
launchOptions:launchOptions];
@benvium
benvium / convert.sh
Created February 15, 2016 18:15
Convert all WAVs in folder to mono 22050khz
for file in *.wav; do ffmpeg -i "$file" -ac 1 -ar 20050 "../WAVout/$file"; done
@benvium
benvium / index.ios.js
Created December 18, 2015 11:35
React Native: Enable Login Button when username and password fields are filled in
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var signalr = require('react-native-signalr');
@benvium
benvium / .sh
Last active March 18, 2016 09:07
Gitignore file for Android Studio projects in Calvium
########################################
#
# Calvium Android .gitignore
#
########################################
# Android NDK
**/src/main/obj
**/src/main/libs
@benvium
benvium / jsonExport.js
Last active November 27, 2015 16:45
Google Apps script JSON export. Adapted from http://blog.pamelafox.org/2013/06/exporting-google-spreadsheet-as-json.html. The only actual difference so far is that if the user has an array literal with a missing comma etc, an error is thrown with the details. Previously the script would just fail.
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
// Adapted from http://blog.pamelafox.org/2013/06/exporting-google-spreadsheet-as-json.html
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@benvium
benvium / getPackageName.sh
Last active January 7, 2021 10:00
Script to extract the android package id (app id) from an android apk file, and another to uninstall an app when you have the apk handy.
# extract the android package id from a built apk file
# usage ./getPackageName.sh <path-to-apk>
line=`aapt dump badging "$1" | grep package:\ name`
# above returns:
# package: name='com.calvium.myapp' versionCode='1' versionName='1.0'
if [[ $line =~ name=\'(.+)\'\ versionCode ]]; then
echo ${BASH_REMATCH[1]}
else
echo "Failed to find package name"