Skip to content

Instantly share code, notes, and snippets.

View itzsaga's full-sized avatar
🍕

Seth itzsaga

🍕
View GitHub Profile
@itzsaga
itzsaga / instrumentation.node.ts
Last active December 11, 2023 21:23
Datadog APM w/ OTEL in Next.js in standalone mode
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node'
const tracer = require('dd-trace').init()
const { TracerProvider } = tracer
const provider = new TracerProvider({
resource: new Resource({
<template>
<section>
<b-form @submit="onSubmit" @reset="onReset">
<b-form-group id="input-group-name" label="First Name:" label-for="input-name">
<b-form-input
:disabled="disabled"
id="input-name"
v-model="form.name"
required
placeholder="Enter first name (required)"
@itzsaga
itzsaga / minify.js
Last active April 21, 2020 14:23
Minification of a dist folder preserving swagger comments
var Terser = require("terser");
var fs = require("fs");
var path = require("path");
// This function takes a path and returns an array of the
// file paths in that directory that satisfy the requirements
function getAllFiles(dirPath, arrayOfFiles) {
let files = fs.readdirSync(dirPath);
arrayOfFiles = arrayOfFiles || [];
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@itzsaga
itzsaga / nestedState.js
Created December 11, 2018 17:30
Updating React nested state.
this.setState(prevState => ({
...prevState,
someProperty: {
...prevState.someProperty,
someOtherProperty: {
...prevState.someProperty.someOtherProperty,
anotherProperty: {
...prevState.someProperty.someOtherProperty.anotherProperty,
flag: false
}
@itzsaga
itzsaga / custom.css
Created January 20, 2018 03:24
The code from my Bootstrap live lecture for Flatiron School.
.navbar {
margin-bottom: 0;
}
body {
background: #3E4649;
color: #f7f7f7;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
@itzsaga
itzsaga / 1ruby.md
Last active November 11, 2017 23:28
Example code for my Good Code vs. Bad Code Flatiron School study group.

Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 integers. No floats or empty arrays will be passed.

For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7.

[10, 343445353, 3453445, 3453545353453] should return 3453455.

Hint: Do not modify the original array.

function reverse (str) {
return str.split('').reverse().join('')
}
function reverseSentence (str) {
var splitString = str.split(' ')
for (let i = 0; i < splitString.length; i++) {
splitString[i] = reverse(splitString[i])
}
var reversed = splitString.join(' ')
# /config/initializers/cors.rb
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'localhost:3000'
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
// fetch places
function fetchPlaces () {
return (dispatch) => {
dispatch({type: 'FETCH_PLACES'})
return fetch('http://localhost:3001/api/places')
.then(response => {
response.json()
.then(json => {
dispatch({type: 'RECEIVED_PLACES', payload: json})
})