Skip to content

Instantly share code, notes, and snippets.

View georgelima's full-sized avatar
:shipit:
hey bro, what's up?

George Lima georgelima

:shipit:
hey bro, what's up?
View GitHub Profile
@guilhermedecampo
guilhermedecampo / multiple-push-urls.md
Created February 1, 2019 12:24 — forked from bjmiller121/multiple-push-urls.md
Add multiple push URLs to a single git remote

Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.

Once you have a remote set up for one of your upstreams, run these commands with:

git remote set-url --add --push [remote] [original repo URL]
git remote set-url --add --push [remote] [second repo URL]

Once set up, git remote -v should show two (push) URLs and one (fetch) URL. Something like this:

{ _events: [Function],
_eventsCount: [Function],
_maxListeners: [Function],
setMaxListeners: [Function],
getMaxListeners: [Function],
emit: [Function],
addListener: [Function],
on: [Function],
prependListener: [Function],
once: [Function],
@sibelius
sibelius / removeCascadeMongoose.js
Created July 25, 2018 12:34
Remove cascade for mongoose
import mongoose from 'mongoose';
import connectDatabase from '../src/common/database';
// this is needed to load all models in mongoose.models
// eslint-disable-next-line
import * as M from '../src/models';
const removeCascade = async (modelName: string, _id: string) => {
const modelNames = Object.keys(mongoose.models);
@dleske
dleske / k8s-update-secret.md
Last active January 29, 2024 17:12
k8s: Updating a Secret

Hopefully helped another k8s newbie with the following. The question was, how do you update a single key in a secret in k8s? I don't know anything about secrets but I will probably want to know this in the future, so here we go.

First, to create a dummy secret:

apiVersion: v1
kind: Secret
metadata:
  name: test-secret
data:
@charltoons
charltoons / autoconfirm.js
Created August 26, 2017 14:21
AWS Cognito Lambda PreSignup Auto-Confirm Trigger
'use strict';
exports.handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2))
const modifiedEvent = event
// check that we're acting on the right trigger
if (event.triggerSource === "PreSignUp_SignUp"){
// auto confirm the user
@vlucas
vlucas / encryption.js
Last active June 7, 2024 04:27
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
##### Replace 'example' anywhere with the name of your app and '*ec2ip*' with your ec2 instance ip
##### Set up your instance and make sure it's security group has ssh, http, and https open inbound and outbound
##### Don't forget to chmod 400 cert.pem
##### .deliver/config
APP="example"
BUILD_HOST="*ec2ip*"
BUILD_USER="elixir_builder"
BUILD_AT="/home/$BUILD_USER/edeliver/$APP/builds"
@ahmadshah
ahmadshah / README.md
Last active January 6, 2021 15:21
Ecto Soft Delete

Soft Delete Ecto Repo

The goal is to support soft delete functionality in Ecto.Repo. With the suggestion by @imranismail, another repo is created and the remaining functionalities are delegate to the original MyApp.Repo.

The new repo get/2 and all/1 functions will exclude the soft deleted record by default. delete/1 and delete_all/1 will update the delete_at column by default instead of deleting.

Example

MyApp.Repo.get(MyApp.User, 1) //will return nil if record is in soft delete state