Skip to content

Instantly share code, notes, and snippets.

View sammyteahan's full-sized avatar

Sam Teahan sammyteahan

View GitHub Profile

#Layout Component:

Internal Layout Styles:

Internal styles are styles that are applied to a component to style all its inner (immediate) children from border inward. The goal of this is to keep components as dynamic as possible by only defining what itself should always look like. We don't worry about where it is on the page or how is should look along side other components.

Internal layout styles include:

  • alignContent
@kentcdodds
kentcdodds / README.md
Last active March 11, 2021 01:41
JavaScript Program Slicing with SliceJS
@jarretmoses
jarretmoses / React Native Clear Cache
Last active March 11, 2024 10:20
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@RussMax783
RussMax783 / actions.js
Created April 20, 2016 17:12
Setting up a socket connection in React/native app. put the socket instance in the store and make sure there is only one socket. Then set up your socket listeners and actions to dispatch when events come through
import connectSocket from './socketConfig';
export const INITIALIZE_SOCKET = 'INITIALIZE_SOCKET';
export const SOCKET_CONNECTED = 'SOCKET_CONNECTED';
export const SOCKET_DISCONNECTED = 'SOCKET_DISCONNECTED';
export const UPDATE_NETWORK_STATUS = 'UPDATE_NETWORK_STATUS';
export const SIGNED_OUT = 'SIGNED_OUT';
function socketInitialized(socket) {
@thanos
thanos / group.py
Created December 16, 2015 14:47
A custom django has_group conditional tag for testing if a user belongs to a group in a django template.
# A custom django has_group conditional tag
# usage:
#
# {% if request.user|has_group:"Manager" %} {% endif %}
#
# Developer: Thanos Vassilakis, 2002
import re, string
from django import template
@mireq
mireq / time_series.py
Last active August 11, 2020 15:33
Django ORM time series
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from collections import namedtuple
from datetime import datetime, date, time, timedelta
from functools import partial
from django.db import models
from django.db.models.expressions import DateTime, Date
from django.utils import timezone
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
# Node-WebKit CheatSheet
# Download: https://github.com/rogerwang/node-webkit#downloads
# Old Versions: https://github.com/rogerwang/node-webkit/wiki/Downloads-of-old-versions
# Wiki: https://github.com/rogerwang/node-webkit/wiki
# How: https://github.com/rogerwang/node-webkit/wiki/How-node.js-is-integrated-with-chromium
# 1. Run your application.
# https://github.com/rogerwang/node-webkit/wiki/How-to-run-apps