Skip to content

Instantly share code, notes, and snippets.

View thekarel's full-sized avatar

Charles Szilagyi thekarel

View GitHub Profile
@thekarel
thekarel / main.dart
Created August 9, 2019 13:44
Get lat/lon of a place selected via autocomplete dialog
// Using https://github.com/fluttercommunity/flutter_google_places
import 'package:flutter/material.dart';
import 'package:flutter_google_places/flutter_google_places.dart';
import 'package:google_maps_webservice/places.dart';
const googleApiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: googleApiKey);
void main() => runApp(MyApp());
@thekarel
thekarel / flutter-google.md
Last active August 10, 2019 13:05
Enable Google Auth with Firebase in a Flutter app

Get your SHA keys:

Production:

keytool -list -v -alias <your-key-name> -keystore <path-to-production-keystore>

For the debug key, look at https://stackoverflow.com/a/56091158 or run keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Finally, the google play ones are on https://play.google.com/apps/publish/ > App signing

@thekarel
thekarel / constructor.dart
Created August 7, 2019 21:38
Dart constructor arguments
void main() {
final food = Food('good', price: 3);
print('${food.taste} ${food.price.toString()}');
}
class Food {
Food(this.taste, {this.price});
final String taste;
@thekarel
thekarel / ocadonutrition.js
Created July 31, 2019 15:05
Bookmarklet: Copy nutrition information from Ocado
javascript:var vals = window.getSelection().toString().split('\n').map(row => {const cells = row.split('\t'); return cells[1]}).map(val => val.replace(/(g|kcal)$/, '')).join('\t');navigator.clipboard.readText(vals).then(() => alert(vals)).catch(err => alert(err))
@thekarel
thekarel / bitbucket_ssh.sh
Created April 25, 2019 08:04
Save Bitbucket SSH key
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
@thekarel
thekarel / getEnvConfigOrThrow.js
Created April 16, 2019 09:01
Get config from environment or throw error
const getEnvConfigOrThrow = (requiredKeys, env) => {
const config = requiredKeys.reduce(
(result, key) => ({
...result,
[key]: env[key],
}),
{},
)
const missingConfig = Object.entries(config).reduce(
@thekarel
thekarel / omit.spec.ts
Created April 2, 2019 22:14
Omit an array element
import {omit} from './omit'
describe(`Omit`, () => {
it(`removes item with index from array`, async () => {
const arr = [1, 2, 3]
expect(omit(0, arr)).toEqual([2, 3])
})
})
@thekarel
thekarel / wim.md
Created February 22, 2019 12:26
Use symlinked packages in react-native

Install wml (https://github.com/wix/wml)

Add the link to wml using wml add <src> <dest>

wml add ~/my-package ~/main-project/node_modules/my-package

Start watching all links added

wml start

@thekarel
thekarel / ip.sh
Created January 24, 2019 10:27
Find own IP address on OS X
# LAN IP
ipconfig getifaddr en0
@thekarel
thekarel / javahome.sh
Created January 24, 2019 09:07
JAVA HOME on OS X
export JAVA_HOME="$(/usr/libexec/java_home)"