Skip to content

Instantly share code, notes, and snippets.

View danman01's full-sized avatar

Danny Kirschner danman01

View GitHub Profile
@danman01
danman01 / json.md
Created December 14, 2017 18:53
what is JSON?

What is JSON?

JavaScript Object Notation or JSON is a text-notation format for the serialization of structured data. The JSON format describes how to represent and structure the data so that it can easily written, transferred and parsed by the receiver. JSON is easy for humans to read and write. It’s also easy for machines to programmatically parse and generate. By looking at a document structured using the JSON format, one can visually read the data and the structure of the data, such as how data is related to other data parent or child item. This ease of use has made JSON one of the most popular ways to format and interchange data.

The reason one might use the JSON format to structure their data is to provide for ease of serialization. That means the data can easily be translated from an object into a format that can be stored (for example, in a file) or transmitted (for example, across a network). JSON can represent four primitive data types: String, Number, Boolean and Null, as well as two structured t

@danman01
danman01 / update_post_fullstack_project.rb
Last active September 10, 2017 22:07
update_post_fullstack_project.sh
##########
######
###### As a new user with ID 2:
[email protected]: blog_rails-api-template (dk)* $ [email protected] PASSWORD=q123 sh scripts/sign-up.sh
HTTP/1.1 201 Created
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
@danman01
danman01 / atom_teach_resize.sh
Created August 29, 2017 23:57
atom_teach_resize
#!/bin/bash
# source into your .bash_profile
# call with atom_teach_resize and turn off with atom_teach_resize off
function atom_teach_resize() {
if [[ ! "$1" = "off" ]] && [[ ! -z "$1" ]]; then
echo "arg1: only \"off\" acceptable!"
exit
elif [[ ! -z "$1" ]]; then
COMMENT="//"
@danman01
danman01 / deploy.log
Created August 13, 2017 02:09
heroku ember-cli-rails deploy log
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
1.upto(10) do |i|
puts "i"
return 'hey I\'m returning!'
end
# what is returned? Why?
def count(upto)
msg = 'hey I\'m returning!'
1.upto(upto) do |i|
puts 'i'
@danman01
danman01 / generate_secrets.sh
Created July 26, 2017 02:53
generate secrets for rails projects
function generate_secrets {
echo SECRET_KEY_BASE_DEVELOPMENT=`bundle exec rake secret` | tee .env && echo SECRET_KEY_BASE_TEST=`bundle exec rake secret` | tee -a .env
}
@danman01
danman01 / reference_type_change_in_function.js
Created July 24, 2017 16:56
changing props of reference type within function
> const menu = {
... 'burger': 5.99,
... 'salad': 4.99,
... 'drink': 1.00
... }
undefined
> menu
{ burger: 5.99, salad: 4.99, drink: 1 }
> const addProperty = function addProperty(obj, prop, val) {
... obj[prop] = val
@danman01
danman01 / rails_association_testing.rb
Last active May 12, 2017 15:28
verifying rails associations exist
# belongs_to side contains the foreign key
class Comment < ActiveRecord::Base
belongs_to :example
end
# has_one side does not contain the foreign key
class Example < ApplicationRecord
belongs_to :user
has_one :comment
validates :text, :user, presence: true
@danman01
danman01 / rubocop_warnings.sh
Created April 4, 2017 16:55
rubocop output of ruby array methods
[email protected]: ruby-array-methods (lm01/master)* $ bin/rake
Running RuboCop...
Inspecting 25 files
..CCCCCCC.CCCCCCCCWCCCC..
Offenses:
bin/cities_array.rb:1:1: C: Missing magic comment # frozen_string_literal: true.
require_relative '../lib/cities.rb'
^
@danman01
danman01 / bash_prompt_customization.sh
Created March 21, 2017 01:38
bash_prompt_customization.sh
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
parse_git_dirty() {
st=$(git status 2>/dev/null | tail -n 1)
if [[ $st == "" ]]; then
echo ''
elif [[ $st == "nothing to commit (working directory clean)" ]]; then
echo ''