Skip to content

Instantly share code, notes, and snippets.

View unyo's full-sized avatar

Cody Moniz unyo

View GitHub Profile
@akbarsha03
akbarsha03 / ReactNativeActivity.java
Last active September 9, 2021 02:44
A simple react native activity
package com.sample.reactapp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.KeyEvent;
import android.widget.Toast;
@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));

How to disable page caching with create-react-app

If you currently not using a service worker resulting in old production caches being used and users not getting new versions of the app.

src/index.js

Use:

import { unregister as unregisterServiceWorker } from './registerServiceWorker'
@spara
spara / docker-ce-17.05-ubuntu-16.04-LTS-install.md
Last active August 9, 2023 09:04
Install Docker CE 17.05 and Compose 1.13.0

Installing Docker CE Edge for Ubuntu Linux

Remove previous versions of Docker and Compose

sudo apt-get purge docker-compose
sudo apt-get purge docker-ce

Install dependencies

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

@ddm
ddm / share-vpn.sh
Last active May 9, 2018 22:09
Share openvpn/tunnelblick connection on Mac OSX Sierra
#!/usr/bin/env bash
DIR=`dirname $0`
echo 'nat on en0 from $localnet to any -> (en0)' > $DIR/share-vpn.rules
sudo pfctl -f $DIR/share-vpn.rules -e
echo "Use 'sudo pfctl -F all' to clear NAT rules"
@simenbrekken
simenbrekken / schema.js
Created December 21, 2016 14:06
Firebase backed GraphQL schema
import firebase from 'firebase'
import { filter, map } from 'lodash'
import { makeExecutableSchema } from 'graphql-tools'
firebase.initializeApp({
databaseURL: 'https://grafire-b1b6e.firebaseio.com',
})
const mapSnapshotToEntity = snapshot => ({ id: snapshot.key, ...snapshot.val() })
const mapSnapshotToEntities = snapshot => map(snapshot.val(), (value, id) => ({ id, ...value }))
import sinonStubPromise from 'sinon-stub-promise';
import sinon from 'sinon'
sinonStubPromise(sinon)
let stubedFetch = sinon.stub(window, 'fetch') )
window.fetch.returns(Promise.resolve(mockApiResponse()));
function mockApiResponse(body = {}) {
@mxstbr
mxstbr / Readme.md
Last active December 20, 2023 12:01
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
@oznu
oznu / README.md
Last active May 12, 2024 03:42
How to Bootcamp / Dual Boot Windows 10 on a mid-2011 iMac using USB

How to Install / Bootcamp Windows 10 on a mid-2011 iMac using USB

Apple has released support for bootcamping Windows 10, but only on 2012 Macs and later. Despite not being supported. it is possible to install Windows 10 on earlier iMacs and it seems to run quite well.

IMPORTANT: Unplug all external and physical hard drives (where possible) that you won't be installing to to avoid accidentally erasing them. Also make note of which drives and partitions remain (e.g. System and Storage hard drives), and be super careful to not erase the wrong one.

RECOVERY: If you nuke your machine, restore your time machine backup. Instructions here.

Requirements