$ npm install -g create-react-app
$ create-react-app my-app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// One of my new favorite React Hook patternms is to create handler | |
// functions for a custom hook using `React.useMemo` instead of | |
// `React.useCallback`, like so: | |
function useBool(initialState = false) { | |
const [state, setState] = React.useState(initialState) | |
// Instead of individual React.useCallbacks gathered into an object | |
// Let's memoize the whole object. Then, we can destructure the | |
// methods we need in our consuming component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALL JAVA | |
$ sudo apt-get update && sudo apt-get install default-jre | |
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html | |
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list | |
$ sudo apt-get update && sudo apt-get install elasticsearch | |
$ sudo update-rc.d elasticsearch defaults 95 10 | |
$ sudo service elasticsearch restart | |
$ sudo service elasticsearch status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('https'); | |
var querystring = require('querystring'); | |
// set the post request options | |
var reqOptions = { | |
hostname: 'hooks.slack.com', | |
port: 443, | |
path: '/services/YOUR/SLACK/HOOK_HERE', | |
method: 'POST' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
const PASSWORD = '!!!!!sufficiently_long_password!!!!!'; | |
const CIPHER_METHOD = 'AES-256-CBC'; | |
function encrypt($str) { | |
$iv_length = openssl_cipher_iv_length(CIPHER_METHOD); | |
$iv = mcrypt_create_iv($iv_length, MCRYPT_RAND); | |
$str = $iv.$str; | |
$val = openssl_encrypt($str, CIPHER_METHOD, PASSWORD, 0, $iv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sidekiq interaction and startup script | |
commands: | |
create_post_dir: | |
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post" | |
ignoreErrors: true | |
files: | |
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh": | |
mode: "000755" | |
owner: root | |
group: root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Insert an attachment from a URL address. | |
* | |
* @param string $url The URL address. | |
* @param int|null $parent_post_id The parent post ID (Optional). | |
* @return int|false The attachment ID on success. False on failure. | |
*/ | |
function wp_insert_attachment_from_url( $url, $parent_post_id = null ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Git needed for Git based gems | |
packages: | |
yum: | |
git: [] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[cyan]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
#Customized git status, oh-my-zsh currently does not allow render dirty status before branch | |
git_custom_status() { | |
local cb=$(current_branch) | |
if [ -n "$cb" ]; then | |
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" |
NewerOlder