Skip to content

Instantly share code, notes, and snippets.

@dreadjr
dreadjr / jq-insert-var.sh
Created January 4, 2019 22:45 — forked from joar/jq-insert-var.sh
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{
@dreadjr
dreadjr / RNMultipleTargetsInstructions.md
Created November 20, 2018 23:35 — forked from jacks205/RNMultipleTargetsInstructions.md
Settings up multiple app targets in React-Native
@dreadjr
dreadjr / react-native-deployments.md
Created November 20, 2018 21:59 — forked from ptgamr/react-native-deployments.md
Environment configurations for React Native App

Intro

If you ever need a mobile application, you probably have an API endpoint to talk to. And if you're doing it right, you should have different environment for your API, usually it'll be: dev, staging, production.

The problem: How do we do the testing for our app?

We dont' want to perform test againts the production API. We need a way to teach our app to talk to different API environment. But what is the switch?

The naive way:

@dreadjr
dreadjr / registry-images.sh
Created September 5, 2018 16:06 — forked from adampats/registry-images.sh
Docker Registry v2 API list images and tags
# Assumes htpass authentication
registry_server='docker.mycloud.com'
username='bob'
# List all images (i.e. repositories)
curl -k -X GET "https://$registry_server/v2/_catalog" -u $username -H "Accept: application/json"
Enter host password for user 'bob':
{"repositories":["app-base","ubuntu","cache-base"]}
curl "YOUR_WEBHOOK" -d '{"text":"https://twitter.com/cdixon/status/591658510007410688"}'
@dreadjr
dreadjr / generate-pushid.js
Created May 11, 2018 16:58 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@dreadjr
dreadjr / app.js
Created May 3, 2018 22:34 — forked from ajl100b/app.js
Redirect to search results component upon submit of search terms from search bar embedded in a global navbar
import React, { Component } from 'react'
import { Redirect } from 'react-router'
export default class Search extends Component {
constructor () {
super();
this.state = {
fireRedirect: false
}
}
@dreadjr
dreadjr / loadModel.py
Created April 13, 2018 20:17 — forked from vgpena/loadModel.py
Basic text classification with Keras and TensorFlow
import json
import numpy as np
import keras
import keras.preprocessing.text as kpt
from keras.preprocessing.text import Tokenizer
from keras.models import model_from_json
# we're still going to use a Tokenizer here, but we don't need to fit it
tokenizer = Tokenizer(num_words=3000)
# for human-friendly printing
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@dreadjr
dreadjr / LinkedIn_500_API_error.php
Created March 19, 2018 09:58 — forked from sunils34/LinkedIn_500_API_error.php
Description of API request that receives a Linkedin 500 (Internal service error).
//URL: https://api.linkedin.com/v1/people/~/shares
//Request params:
Array
(
[content] => Array
(
[submitted-url] => http://forestnation.com/
[title] => Imagine ForestNation
[submitted-image-url] => http://forestnationcdn.forestnation.netdna-cdn.com/wp-content/uploads/2013/05/FN-World-150.png
[description] => Imagine a world where everyone grows their own tree. You plant one We plant one - Imagine ForestNation.