Skip to content

Instantly share code, notes, and snippets.

View benjaminadk's full-sized avatar
👩‍💻
forever coding

Benjamin benjaminadk

👩‍💻
forever coding
View GitHub Profile
@benjaminadk
benjaminadk / datamodel.graphql
Last active November 28, 2018 02:00
chingu7 graphql data model
type User {
id: ID! @unique
name: String!
email: String! @unique
image: String
password: String # tradition email/password login
oauthId: String # if oauth login is used
posts: [Post]
reviews: [Review]
createdAt: DateTime!
@benjaminadk
benjaminadk / models.js
Last active November 26, 2018 19:36
chingu-7-data-model
const categories = ['react', 'jquery', 'angular', 'vue']
const subCategories = ['documentation', 'tutorial', 'book']
const user = {
id: String, // generated by db
username: String, // unique
password: String, // if we use text password
email: String, // unique
oauthId: String, // if we use oauth
@benjaminadk
benjaminadk / timer.js
Created November 12, 2018 01:12
Simple Timer
class Component extends React.Component {
constructor(props) {
super(props)
this.state = {
time: null
}
}
componentDidMount() {
@benjaminadk
benjaminadk / download-json.js
Created November 6, 2018 04:10
Exam Simulator - Download JSON
// Example State
this.state = {
name: "Johnny Smitherson",
age: "47",
employed: true
}
// Method to download as JSON file
downloadFile = () => {
const {name, age, employed} = this.state
@benjaminadk
benjaminadk / question.js
Created November 5, 2018 23:24
Exam Simulator - Example Question
{
variant: 1, // variant 1 for multiple-answer
question: [ // variant 1 for small text
{variant: 1, text: "Which two characters are convicted for the murder of Teresa Halbach?"}
],
choices: [ // sequential labels
{label: "A", text: "Earl Avery"},
{label: "B", text: "Chuck Avery"},
{label: "C", text: "Steve Avery"},
{label: "D", text: "Bobby Dassey"},
@benjaminadk
benjaminadk / exam.js
Created November 5, 2018 22:17
Exam Simulator - JSON Format
// Exam Object
{
title: String, // Title of the exam - ex: "Network Administration"
code: String, // Optional 6 digit code - popular for technical certification exams - ex: "123-456"
pass: Number, // Passing score as a percentage - ex: 75
time: Number, // Time limit of exam in minutes - ex: 90
cover: [Node], // Array of Nodes - A way to visualize exam
test: [Questions] // Array of Questions - All questions that make up the exam
}
@benjaminadk
benjaminadk / build.js
Created October 6, 2018 02:35
A simple Electron build field configuration for Windows
// build field from package.json
// productName - Output executable will be based on this, the official name of the app
// win - means we are targeting Windows
// icon - the icon for the executable file, taskbar, shortcuts, etc
// publish - automatically pushes the executable to a distribution platform
// provider - i am using github releases - people can go there and download my app
// owner - my github name
// target - type of build, there are more options for Windows - appx, squirrel as well as MacOS and Linux options
// directories - by default input dir is dist, here output is assigned to release - all built files will end up there
"build": {
@benjaminadk
benjaminadk / capture-snapshot.js
Created October 5, 2018 23:18
Takes a incoming stream and creates a snapshot image using canvas
// Earlier in your code
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
// Capture a stream and this function will create a snapshot
function captureSnapshot(stream) {
// Create a video element and style it so it is way off the screen
var video = document.createElement('video')
video.style.cssText = 'position: absolute; left: -10000px; top: -10000px;'
@benjaminadk
benjaminadk / index.html
Created June 27, 2018 19:41
Pomodoro Clock
<div id="root"></div>
@benjaminadk
benjaminadk / schema.js
Created July 31, 2017 01:56
my thoughts on schema
const userSchema = mongoose.Schema(
{
login: loginSchema
profile: profileSchema
skillTree: skillSchema
})
const loginSchema = mongoose.Schema(
{
username: {