Skip to content

Instantly share code, notes, and snippets.

@threepointone
threepointone / 0 basics.md
Last active March 21, 2023 01:53
css-in-js

A series of posts on css-in-js

0. styles as objects

First, an exercise. Can we represent all of css with plain data? Let's try.

let redText = { color: 'red' };
@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@MPiccinato
MPiccinato / RCCNavigationController.m
Last active January 30, 2018 04:01
RCCNavigationController white flash temp fix
#import "RCCNavigationController.h"
#import "RCCViewController.h"
#import "RCCManager.h"
#import <React/RCTEventDispatcher.h>
#import <React/RCTConvert.h>
#import <React/RCTRootView.h>
#import <objc/runtime.h>
#import "RCCTitleViewHelper.h"
#import "RCCCustomBarButtonItem.h"
#import "UIViewController+Rotation.h"
@grimzy
grimzy / git-pull-all
Created September 15, 2017 02:15
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@stubailo
stubailo / fetch-graphql.js
Created September 5, 2017 08:15
Call a GraphQL API with fetch
require('isomorphic-fetch');
fetch('https://1jzxrj179.lp.gql.zone/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: '{ posts { title } }' }),
})
.then(res => res.json())
.then(res => console.log(res.data));
@threepointone
threepointone / glam-for-css-folks.md
Last active September 4, 2022 07:43
why css purists will love glam

I made a little styling lib called glam

(some features are in development)

one

let's start off with the simplest use case. we'll make an 'index.html' page, and assume we've setup our js bundler to output bundle.js

@cooperka
cooperka / ListView to FlatList.diff
Last active June 18, 2020 05:36
Migrating from ListView to FlatList in React Native.
-import { Text, View, ListView } from 'react-native';
+import { Text, View, FlatList } from 'react-native';
import style from './styles';
import listData from './listData';
class App extends Component {
- constructor(props) {
- super(props);
@raphaellondner-mongodb
raphaellondner-mongodb / lambda-mongodb-example
Last active March 11, 2020 02:37
MongoDB-Lambda-Example
'use strict'
const AWS = require('aws-sdk');
var MongoClient = require('mongodb').MongoClient;
let atlas_connection_uri;
exports.handler = (event, context, callback) => {
var uri = process.env['MONGODB_ATLAS_CLUSTER_URI'];
if (atlas_connection_uri != null) {
@AndrewJack
AndrewJack / build.gradle
Created February 14, 2017 09:40
React Native Android Library SDK Versions
subprojects {
ext {
compileSdk = 25
buildTools = "25.0.1"
minSdk = 19
targetSdk = 25
}
afterEvaluate { project ->
if (!project.name.equalsIgnoreCase("app")
@sibelius
sibelius / Info.plist
Created November 17, 2016 15:34
ios 10 permissions
<!-- 🖼 Photo Library -->
<key>NSPhotoLibraryUsageDescription</key>
<string><Your description goes here></string>
<!-- 📷 Camera -->
<key>NSCameraUsageDescription</key>
<string><Your description goes here></string>
<!-- 🎤 Microphone -->
<key>NSMicrophoneUsageDescription</key>