Skip to content

Instantly share code, notes, and snippets.

View rudin's full-sized avatar

Rudin Swagerman rudin

View GitHub Profile
@rudin
rudin / loadjson.js
Created October 30, 2015 10:54
Load a local json in your Cordova app
Add to app .plst
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
var getJSON = function(url) {
return new Promise(function(resolve, reject) {
@rudin
rudin / index.js
Last active November 9, 2016 16:36
Rewritten (ES6) React Component for Icons using Inline SVG
// http://dmfrancisco.github.io/react-icons/
// http://www.rudinswagerman.nl/
/*
<Icon size="2rem" icon="my-icon" />
*/
import React from 'react';
const renderGraphic = icon => {
@rudin
rudin / Hover.js
Last active September 28, 2016 10:22
React, Swap between two children on hover
// swap children on hover
/*
<Hover>
<span>this</span>
<span>that</span>
</Hover>
*/
import React, { Component } from 'react';
export default class Hover extends Component {
constructor () {
@rudin
rudin / example.txt
Last active November 23, 2016 10:11
Iterating the react way...
// Like this:
const Item = ({value}) => <li>{value}</li>;
const Iteration = ({data}) => (
<ul>
{data.map((value, index) => <Item key={index} value={value}/>)}
</ul>
);
@rudin
rudin / json.json
Created September 25, 2017 10:30
json referentie
"data": {
"id": 8271,
"name": "The Wall",
"slug": "the-wall",
"customer": {
"id": 7643,
"name": "BNP Nogwat"
},
"products": [
{
@rudin
rudin / deploy-rollback.txt
Last active April 9, 2018 09:56
Create React App - Deploy and Rollback scripts
It's annoying to see the build folder being removed while a new build is being created. Error 500 for as long as the build takes...
Instead of 'build', the 'live' folder is being served to the client.
When the build has succeeded, the 'live' folder is being renamed to 'backup', and the 'build' is being renamed to 'live' to take its place. On rollback, the 'backup' will be put back into place.
"removeBackup": "! test -d backup || rm -r ./backup",
"removeRevoked": "! test -d revoked || rm -r ./revoked",
"renameLiveToBackup": "! test -d live || mv ./live ./backup",
"renameLiveToRevoked": "! test -d live || mv ./live ./revoked",
"renameBackupToLive": "! test -d backup || mv ./backup ./live",
@rudin
rudin / Stack.js
Last active May 4, 2020 13:58
React(Native) Stack Component (Whitespace defined by parent)
import React, { Fragment } from "react"
import { View } from "./"
const Stack = ({ children, gap = 2, ...rest }) => {
const Wrapper = Object.keys(rest).length > 0 ? View : Fragment
const childrenWithProps = React.Children.map(children, (child, index) => {
if (!child) return null
if (index === 0 || index === children.length - 1) {
return child
}
@rudin
rudin / data
Created January 20, 2020 12:35
var data = {
"title": "flare",
"children": [
{
"title": "analytics",
"children": [
{
"title": "cluster",
"children": [
{ "title": "AgglomerativeCluster", "value": 3938 },