Skip to content

Instantly share code, notes, and snippets.

@bultas
bultas / gist:3fcd11d8e5e31e93562d
Created March 18, 2015 21:24
GIT - how to replace master branch with another branch
http://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch
You should be able to use the "ours" merge strategy to overwrite master with AnotherBranch like this:
git checkout AnotherBranch
git merge -s ours master
git checkout master
git merge AnotherBranch
The result should be your master is now essentially AnotherBranch.
@maisonm
maisonm / userRoutes.js
Last active September 22, 2021 12:34
const jwt = require('jsonwebtoken');
const user = require('../../models/dummyUser');
module.exports = (app) => {
app.post('/user/login', (req, res, next) => {
const { body } = req;
const { username } = body;
const { password } = body;
@erdostom
erdostom / Dockerfile
Last active December 26, 2024 08:25
Good starter Dockerfile + docker-compose.yml for Rails 6.
FROM ruby:2.6.5-alpine
RUN apk add --update --no-cache bash build-base nodejs sqlite-dev tzdata postgresql-dev yarn
RUN gem install bundler:2.1.4
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install --check-files
@yohanmishkin
yohanmishkin / doc.md
Last active December 31, 2019 07:06
Multi-stage builds in docker

Multi-stage builds in docker

Having spent a bit of time working to dockerize an API I wanted to share one of my learnings in case it’s helpful or interesting to others.

Granting access to private git repositories

The first issue I ran into was how to authenticate requests to gems we host privately on Github. We do this quite a bit throughout our repos.

So I needed a way to grant access to our docker image in order for bundler to run properly. Because were trying to build for production deployment I first decided to remove HTTPS repository references (https://github.com/ldock/) and replace them with SSH URLs ([email protected]:ldock/). But this introduced the challenge of getting the private key on the container securely. I needed the ability to get an authorized SSH key on the image when dependencies were being installed (bundle install) but I did not want to leave the key on the file system after the dependencies were installed.

@edmondburnett
edmondburnett / gist:38ed3451de659dc43fa3f24befc0073b
Last active July 12, 2023 14:23
Axios Interceptor to delay and retry original request for certain status code (polling)
import axios from 'axios';
const instance = axios.create({
baseURL: 'http://localhost:5000'
});
const sleepRequest = (milliseconds, originalRequest) => {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(instance(originalRequest)), milliseconds);
});
@zealot128
zealot128 / ActiveStorageDocxPreviewer.md
Last active September 18, 2023 11:18
Activestorage Docx Previewer

Docx (and other Office doc) previewer support for ActiveStorage

Converts all document formats using LibreOffice first to PDF and then to an image, using build-in pdf previwer of ActiveStorage

  • needs: unoconv, a command line tool which uses libreoffice, e.g. apt install unoconv
  • needs a PDF converter, because libreoffice will make a pdf from the office document, Mupdf oder Poppler are already integrated into ActiveStorage, and poppler is free to use, e.g. apt install poppler-utils
@lazaronixon
lazaronixon / _form.html.erb
Last active March 28, 2025 10:19
Dropzone.js + Stimulus + Active Storage + CSS Zero (2025)
<%= form_with(model: billboard) do |form| %>
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %>
<div class="dz-default dz-message flex flex-col items-center">
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %>
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5>
<p class="text-sm text-subtle">Upload up to 10 files.</p>
</div>
<% end %>
<div class="inline-flex items-center mbs-2 mie-1">
import * as humps from 'humps';
/**
* Decamelize form data keys and values
* @param {FormData} formData
* @param {Object} [options]
* @return {FormData}
*/
export const decamelizeFormDataKeys = (formData, options) => {
const decamelizedFormData = new FormData();
@bergmannjg
bergmannjg / rearct-native-app-in-wsl2.md
Last active May 4, 2025 13:20
Building a react native app in WSL2
@obie
obie / _alert.haml
Created October 15, 2020 03:29
Alerts in Reactive Rails style (with Shoelace web components)
%sl-alert.popup-toast{id: id, type: type, open: false, duration: duration, closable: true}
%sl-icon{slot: "icon", name: icon}
- if title.present?
%strong= title
%br
= text