Skip to content

Instantly share code, notes, and snippets.

View anghelalexandra's full-sized avatar

Alexandra Anghel anghelalexandra

View GitHub Profile
@anghelalexandra
anghelalexandra / gist:5517c603ab2d6ade51313537644f9a06
Last active November 1, 2022 09:28
Extract device ID from Google Analytics _ga cookie
/**
* 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 20:33
iOS and Android apps with React Native - Switching between screens with React Native Navigation
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 20:28
iOS and Android apps with React Native - React Native Navigation stack example
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 20:32
iOS and Android apps with React Native - Switching between screens with React Navigation
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 18:48
iOS and Android apps with React Native - React Navigation stack example
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 20:48
iOS and Android apps with React Native - React Component Styling
.w100 {
width: 100%;
background-color: "white";
flex: 1;
}
@anghelalexandra
anghelalexandra / rn-react-native-component-styling.js
Created May 14, 2018 20:46
iOS and Android apps with React Native - React Native Component Styling
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 20:41
iOS and Android apps with React Native - React Native Component
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 20:36
iOS and Android apps with React Native - React Component
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 October 19, 2017 08:17
React component that displays a list of categories received as a prop
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}