Skip to content

Instantly share code, notes, and snippets.

@akkonrad
akkonrad / auth.service.ts
Created October 24, 2022 12:38
auth/auth.service.ts
import { Injectable } from '@nestjs/common';
import {
AuthenticationDetails,
CognitoUser,
CognitoUserPool,
CognitoUserSession,
} from 'amazon-cognito-identity-js';
import { AuthConfig } from './auth.config';
@Injectable()
@akkonrad
akkonrad / auth.controller.ts
Created October 24, 2022 12:38
auth/auth.controller.ts
import { BadRequestException, Body, Controller, Post } from '@nestjs/common';
import { AuthService } from './auth.service';
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Post('login')
async login(@Body() authenticateRequest: { name: string; password: string }) {
try {
@akkonrad
akkonrad / auth.config.ts
Created October 24, 2022 12:36
auth/auth.config.ts
import { Injectable } from '@nestjs/common';
@Injectable()
export class AuthConfig {
public userPoolId: string;
public clientId: string;
public region: string;
public authority;
constructor() {
@akkonrad
akkonrad / type-defs.ts
Last active October 24, 2022 12:30
gql/type-defs.ts
// type-defs.ts
import { gql } from 'apollo-server-express';
export const typeDefs = gql`
type Person {
name: String!
born: Int!
actedInMovies: [Movie!]! @relationship(type: "ACTED_IN", properties: "ActedIn", direction: OUT)
directedMovies: [Movie!]! @relationship(type: "DIRECTED", direction: OUT)
}
@akkonrad
akkonrad / gql.module.ts
Last active October 23, 2022 17:37
app/gql/gql.module.ts
export const gqlProviderFactory = async () => {
const { NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD } = process.env;
const driver = neo4j.driver(
NEO4J_URI,
neo4j.auth.basic(NEO4J_USERNAME, NEO4J_PASSWORD)
);
const neoSchema = new Neo4jGraphQL({
@akkonrad
akkonrad / mongo-db-export.sh
Created May 4, 2018 12:34
mongo database export
#!/bin/bash
# define collections that you want to export. if not defined, nothing will be exported
COLLECTIONS=(collection1 collection2 collection3)
# database access
DB_HOST=${1-'127.0.0.1'}
DB_NAME=${2-'main'}
DB_PORT=${3-'27017'}
DB_USER=${4-'root'}
DB_PASS=${5-''}
@akkonrad
akkonrad / docker_reverting
Created January 17, 2018 17:06 — forked from jclosure/docker_reverting
How to revert a docker container to a previous commit
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
$ docker tag 2844 imagename # <-- that's the secret right there
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
@akkonrad
akkonrad / update-drupal-sites.sh
Created July 13, 2016 10:29
Update drupal sites and create git flow release.
#!/usr/bin/env bash
BASE='/var/www/'
DRUPAL_PROJECTS=('drupalProject1' 'drupalProject2' 'drupalProject3' 'drupalProject4')
RELEASE_NAME="release-$(date +'%Y-%m-%d')"
echo $RELEASE_NAME
for DRUPAL_SITE in ${DRUPAL_PROJECTS[*]}
do
@akkonrad
akkonrad / mixpanel.php
Created June 7, 2016 10:48
PHP/Mixpanel - mass users update (from csv file exported via JQL)
<?php
$mp = Mixpanel(MIXPANEL_KEY);
$path = '/path/to/user/list.csv';
$row = 1;
if (($handle = fopen($path, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// skip header line
@akkonrad
akkonrad / scripts.js
Created March 18, 2015 16:01
Collapsible bug in Bootstrap based themes (Drupal).
// Place in theme file, eg. mytheme/js/script.js
(function($, Drupal, window, document, undefined) {
Drupal.behaviors.bootstrap_based_theme = {
attach : function(context, settings) {
// Fix collapsible bug.
$(".collapse").on("hidden.bs.collapse", function() {
if ($(this).hasClass("in")) {