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
import csv | |
import os | |
import sys | |
import json | |
from PyPDF2 import PdfReader | |
from openai import OpenAI | |
def generate_faq_from_pdf(file_name, model_version="gpt-4o"): | |
# Initialize the OpenAI Client | |
client = OpenAI(api_key="OPEN_AI_API_KEY") |
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
# lib/generators/rails/graphql/graphql_generator.rb | |
# run with "rails generate graphql my_model" | |
class Rails::GraphqlGenerator < Rails::Generators::NamedBase | |
def create_graphql_type_file | |
attributes = "" | |
begin | |
klass = Object.const_get(class_name) | |
obj = klass.new |
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
class EmailInterceptor | |
# just an example to allow only *@zauberware.com emails | |
REGEX_WHITELIST = /.*@zauberware\.com/ | |
def self.delivering_email(message) | |
if !in_whitelist?(message.to.first) | |
message.perform_deliveries = false | |
end | |
end |
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
class BackgroundTaskJob < Struct.new(:background_task_id, :background_task_type) | |
def enqueue(job) | |
check_and_update_status | |
job.delayed_reference_id = background_task_id | |
job.delayed_reference_type = background_task_type | |
job.save! | |
end |
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
Rails.application.routes.draw do | |
constraints(:host => /^(?!old-domain\.com)/i) do | |
match "/(*path)" => redirect { | |
|params, req| "https://new-domain.com/#{params[:path]}" | |
}, via: [:get, :post] | |
end | |
end |
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
#!/bin/bash | |
# Run with $ sh gif.bash -i=InputFile.mov -o=OutputFile | |
for i in "$@" | |
do | |
case $i in | |
-i=*|--input=*) | |
INPUT_FILE="${i#*=}" | |
;; |
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
import styled, { css } from 'styled-components' | |
import { media } from 'styled-bootstrap-grid' | |
import { padding } from 'polished' | |
const Sample = styled.div` | |
/* 1. Default mobile first styles */ | |
${ padding('10px', '14px', '10px', '8px') } | |
color: black; | |
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
// Small jQuery helper to disable buttons while AJAX request is loading. | |
// Init the helper for all buttons on page with $('.js-await-response').awaitResponse() | |
// If a button with your class was klicked, the button itself and all others with that class will be disabled until the response came back | |
(function ( $ ) { | |
$.fn.awaitResponse = function( options ) { | |
var self = this; | |
// listening to starting AJAX events |
NewerOlder