Skip to content

Instantly share code, notes, and snippets.

View balascript's full-sized avatar
💻
cranking...

Bala balascript

💻
cranking...
  • Amazon
  • San Francisco Bay Area
View GitHub Profile
export class CoffeeBrewer{
constructor(name) {
this.beanName = name;
}
brew = () => {
console.log("brewing...", this.beanName);
}
}
export const AnotherCoffeeComponent = props => {
const { coffeeBrewer: { brew } } = props;
return (
<TouchableView
onPress={brew}
>
<Text>Press me!</Text>
</TouchableView>
);
export const CoffeeComponent = (props) => {
const coffeeBrewer = new CoffeeBrewer("DarkRoast");
return (
<TouchableView
onPress={() => {
coffeeBrewer.brew();
}}>
<Text>Press me!</Text>
</TouchableView>
export class CoffeeBrewer{
constructor(name) {
this.beanName = name;
}
brew() {
console.log("brewing...", this.beanName);
}
}
@balascript
balascript / .bash_profile
Created August 10, 2020 01:16
My dev machine bash_profile
# /usr/local/etc/bash_completion.d
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
export ANDROID_HOME="/Users/bramdoss/Library/Android/sdk"
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH="$PATH:$JAVA_HOME/bin"
const UnsplashFeed = props => {
const [photos, fetchMore] = useUnsplashPhotos('dogs');
const renderItem = ({ item, index }) => {
const { uri } = item;
return (
<Image
source={{
uri,
}}
@balascript
balascript / hooks-unsplashPhotos.js
Last active July 12, 2020 20:02
custom hook to provide photos and fetchMore method to be used as a cursor to Flatlist
function useUnsplashPhotos(keyword) {
const [page, setPage] = useState(1);
// default this to true to kick the initial effect hook to
// fetch the first page
const [shouldFetch, setShouldFetch] = useState(true);
const [photos, setPhotos] = useState([]);
// return this function for Flatlist to call onEndReached
const fetchMore = useCallback(() => setShouldFetch(true), []);
@balascript
balascript / fetchPhotos.js
Created July 12, 2020 19:14
function to fetch photos from unsplash API for the given keyword, page, and limit (defaults to 10)
import Unsplash, { toJson } from 'unsplash-js';
const unsplashInstance = new Unsplash({
secret: 'Your secret here',
accessKey: 'Your accessKey here',
});
async function fetchPhotos(keyword, page, limit = 10) {
const photoResult = await unsplashInstance.search
.photos(keyword, page, limit)
"android": {
"sourceDir": "/Users/bala/sample-app/Sample/node_modules/react-native-ble-manager/android",
"folder": "/Users/bala/sample-app/Sample/node_modules/react-native-ble-manager",
"packageImportPath": "import it.innove.BleManagerPackage;",
"packageInstance": "new BleManagerPackage()"
}
$ npx react-native config
{
"root": "/Users/bala/sample-app/Sample",
"reactNativePath": "/Users/bala/sample-app/Sample/node_modules/react-native",
"dependencies": {
"react-native-ble-manager": {
"root": "/Users/bala/sample-app/Sample/node_modules/react-native-ble-manager",
"name": "react-native-ble-manager",
"platforms": {
"android": {