Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexandra Anghel anghelalexandra

View GitHub Profile
@anghelalexandra
anghelalexandra / gist:5517c603ab2d6ade51313537644f9a06
Created May 30, 2022
Extract device ID from Google Analytics _ga cookie
View gist:5517c603ab2d6ade51313537644f9a06
/**
* Get a browser cookie
*
* @param string cname = The cookie name
* @return string = The cookie value or an empty string ("") if the cookie doesn't exist
*/
getCookie = function(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(";");
@anghelalexandra
anghelalexandra / rn-react-native-navigation-screen.js
Created May 15, 2018
iOS and Android apps with React Native - Switching between screens with React Native Navigation
View rn-react-native-navigation-screen.js
import React from 'react';
import PropTypes from 'prop-types';
class LoginScreen extends React.Component {
// ...
componentWillReceiveProps(newProps) {
if (newProps.authenticated === true) {
this.handleSuccessfulLogin();
}
@anghelalexandra
anghelalexandra / rn-react-native-navigation-stack.js
Created May 15, 2018
iOS and Android apps with React Native - React Native Navigation stack example
View rn-react-native-navigation-stack.js
import { Navigation } from 'react-native-navigation';
import Login from './screens/Login';
import Dashboard from './screens/Dashboard';
import Settings from './screens/Settings';
import Posts from './screens/Posts';
import TopBar from './components/TopBar';
export default function registerScreens(store, Provider) {
Navigation.registerComponent('MyApp.Login', () => Login, store, Provider);
Navigation.registerComponent('MyApp.Dashboard', () => Dashboard, store, Provider);
@anghelalexandra
anghelalexandra / rn-react-navigation-screen.js
Last active May 15, 2018
iOS and Android apps with React Native - Switching between screens with React Navigation
View rn-react-navigation-screen.js
import React from 'react';
import PropTypes from 'prop-types';
class LoginScreen extends React.Component {
// ...
componentWillReceiveProps(newProps) {
if (newProps.authenticated === true) {
this.handleSuccessfulLogin();
}
@anghelalexandra
anghelalexandra / rn-react-navigation-stack.js
Created May 15, 2018
iOS and Android apps with React Native - React Navigation stack example
View rn-react-navigation-stack.js
import React from 'react';
import { StackNavigator, DrawerNavigator } from 'react-navigation';
import Loading from './screens/Loading';
import Login from './screens/Login';
import Home from './screens/Home';
import Posts from './screens/Posts';
import Post from './screens/Post';
import Settings from './screens/Settings';
import SideMenu from './screens/SideMenu';
@anghelalexandra
anghelalexandra / rn-react-component-styling.css
Created May 14, 2018
iOS and Android apps with React Native - React Component Styling
View rn-react-component-styling.css
.w100 {
width: 100%;
background-color: "white";
flex: 1;
}
@anghelalexandra
anghelalexandra / rn-react-native-component-styling.js
Created May 14, 2018
iOS and Android apps with React Native - React Native Component Styling
View rn-react-native-component-styling.js
import { StyleSheet } from 'react-native';
export default StyleSheet.create({
w100: {
width: '100%',
backgroundColor: 'white',
flex: 1,
},
});
@anghelalexandra
anghelalexandra / rn-react-native-component.js
Created May 14, 2018
iOS and Android apps with React Native - React Native Component
View rn-react-native-component.js
import React from 'react';
import { View, Text, Image } from 'react-native';
import PropTypes from 'prop-types';
import styles from './styles';
class ExampleRNComponent extends React.Component {
render() {
return (
<View style={styles.w100}>
<View style={styles.menuTitleWrap}>
@anghelalexandra
anghelalexandra / rn-react-component.js
Created May 14, 2018
iOS and Android apps with React Native - React Component
View rn-react-component.js
import React from 'react';
import PropTypes from 'prop-types';
class ExampleWebComponent extends React.Component {
render() {
return (
<div className="w100">
<div className="menuTitleWrap">
<img src={this.props.url} className="shadowImage" alt="" />
</div>
@anghelalexandra
anghelalexandra / categories-list-component.js
Created Oct 19, 2017
React component that displays a list of categories received as a prop
View categories-list-component.js
import React from "react";
import CategoryCard from "./CategoryCard";
const CategoriesList = props => (
<div>
{props.categories.map(element => (
<CategoryCard
key={element.id}
categId={element.id}
src={element.image.src}