Skip to content

Instantly share code, notes, and snippets.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "DataModel")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
@aquaflamingo
aquaflamingo / CustomForm.js
Last active July 17, 2021 17:36
React Custom Form with Hooks Example
import React, { useRef, useState, useEffect } from "react";
const useForm = ({ initialValues, onSubmit }) => {
const [values, setValues] = useState(initialValues || {});
const [errors, setErrors] = useState({});
const [touched, setTouched] = useState({});
const [onSubmitting, setOnSubmitting] = useState(false);
const [onBlur, setOnBlur] = useState(false);
const formRendered = useRef(true);
# post.cr
class Post
YAML.mapping({
name: String,
description: String,
})
end
# factory.cr
module Factory
@aquaflamingo
aquaflamingo / main.go
Created October 25, 2020 17:26 — forked from alyssaq/main.go
GET and POST golang API
/*
* Sample API with GET and POST endpoint.
* POST data is converted to string and saved in internal memory.
* GET endpoint returns all strings in an array.
*/
package main
import (
"encoding/json"
"flag"
# Generate a response array consistent with the requirements of the SPEC.
# @return [Array] a 3-tuple suitable of `[status, headers, body]`
# which is suitable to be returned from the middleware `#call(env)` method.
def finish(&block)
if STATUS_WITH_NO_ENTITY_BODY[status.to_i]
delete_header CONTENT_TYPE
delete_header CONTENT_LENGTH
close
return [@status, @headers, []]
else
@aquaflamingo
aquaflamingo / twbs_rails6.md
Last active December 10, 2020 00:12
Twitter Bootstrap Rails 6

Adding Twitter Bootstrap to Rails 6

See also: https://blog.robsdomain.com/twitter-bootstrap-in-rails-6/

Rails 6 mades large changes to how asset compilation is done. In specific sprockets has been removed for javascript processing and replaced with the common webpack utility. Sprockets remains in usage for CSS processing.

When it comes to asset bundling, the "Rails way" is webpack for JavaScript and Sprockets for everything else. The default setup in a fresh Rail 6 install, similar to what Basecamp uses, still compiles CSS, images, and fonts with Sprockets.

This means, if you're a member of the Basecamp camp, all your webpack JavaScript source files would live in app/javascript and all your Sprockets CSS and images would remain in app/assets. Running rails assets:precompile will first build all the Sprockets assets into the public/assets directory, then will build all the webpack assets into the public/packs directory.

@aquaflamingo
aquaflamingo / circleci-configs.md
Last active July 13, 2020 14:32
Ruby on Rails application .circleci/config.yml (with caching)

CircleCI Configs

Configuration files for CircleCI

@aquaflamingo
aquaflamingo / qvov.md
Created May 18, 2020 12:34
Table for quick view of vue
Software Version What Is It?
Node Version Manager (nvm) latest A Node.js version management software
Node.js v10.11.0 An open source Javascript runtime.
Yarn latest A node package manager tool
Vue CLI 3.10.0 Vue JS command line interface for serving and generating applications