Skip to content

Instantly share code, notes, and snippets.

Avatar
🎮

Gilad Maoz evilUrge

🎮
View GitHub Profile
View stack-lib.ts
import { join } from "path";
import { fileURLToPath } from "url";
import type { Construct } from "constructs";
import { Duration, Stack, StackProps } from "aws-cdk-lib";
import { LogLevel, NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
import { Runtime } from "aws-cdk-lib/aws-lambda";
import { Rule, Schedule } from "aws-cdk-lib/aws-events";
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
@evilUrge
evilUrge / req.js
Created Jun 17, 2022
SSL Pinning
View req.js
const { Agent } = require("https"),
request = require("request");
const FINGERPRINTSET = [
"C3:07:56:2C:08:A5:E1:2E:41:20:10:7A:02:87:86:C3:72:49:45:BF",
];
const req = request(
{
url: "https://www.duckduckgo.com/",
@evilUrge
evilUrge / generateCommonColumns.ts
Created Jan 27, 2022
Create a parquet columns and Glue table columns from a common object
View generateCommonColumns.ts
import { Schema } as GlueSchema from '@aws-cdk/aws-glue';
/**
* Create a parquet columns and Glue table columns from a common object
* @param attributes { name: type }
* @returns {
* parquetSchema: { name: { type: 'type' }, ...},
* glueSchema: [
* { name: 'name', type: 'UTF8' },
* ...
@evilUrge
evilUrge / Paginator.ts
Last active Jun 8, 2022
Aws SDK Paginator
View Paginator.ts
/**
* Paginates over a AWS service function.
* @param functionToExec The function to execute
* @param methodToExec The method to execute
* @param params The parameters to pass to the method
* @param keyToAppend The key to append to the result
* @returns A promise that resolves to an array of results
*/
export async function paginator(
functionToExec: any,
@evilUrge
evilUrge / addUser.js
Last active Jul 12, 2021
Add\remove user automatically to JFrog from a triggered github webhook call
View addUser.js
exports.handler = async (event, context, callback) => {
const
baseJFrogURL = 'https://yourorg.jfrog.io/artifactory',
request = event.Records[0].cf.request,
body = request.body;
switch (body.action) {
case 'added':
const orgEmailAddress = useJeffUserQueryHere(body.member.login) // Your place to shine!
const payload = {
@evilUrge
evilUrge / .fetchRemoteConf.js
Created Sep 1, 2020
Fetch firebase remote config - a script for npm build
View .fetchRemoteConf.js
require('dotenv').config()
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.cert(
process.env.NODE_ENV === 'production'
? require('./gcp.json')
: JSON.parse(process.env.FIREBASE_ADMIN_SDK)
),
databaseURL: process.env.FIREBASE_DATABASE_URL
});
@evilUrge
evilUrge / webhook.py
Last active Oct 13, 2020
Plain webhook - Report for every change in a spesific model based on a pre-exists django WebHook model condition
View webhook.py
import logging
logger = logging.getLogger(__name__)
def report(saved_object):
"""
report is the main function in reporter
# :param uid: django ORM unique identifier; for internal usage.
@evilUrge
evilUrge / view.py
Last active Oct 13, 2020
Django external webhook view
View view.py
import logging
from json import loads
from django.apps import apps
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.core.serializers import serialize
from django.http import JsonResponse
logger = logging.getLogger(__name__)
@evilUrge
evilUrge / firebase-deploy.js
Created May 2, 2019
Deploy to firebase with any CI
View firebase-deploy.js
const fs = require('fs');
const token = process.env['FIREBASE_TOKEN']; // Keep your firebase cli token in FIREBASE_TOKEN as a env param
const projectName = (JSON.parse(fs.readFileSync(`${__dirname}/.firebaserc`, 'utf8')))
.projects[process.env.NODE_ENV ? process.env.NODE_ENV : 'default'];
/**
* FireBase Deployment script
* FOR CI USE ONLY!
*/
@evilUrge
evilUrge / fetch.js
Last active May 2, 2019
Fetch configurations from Firestore's collection "configurations" as json files.
View fetch.js
process.env.NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
require('../src/firebase').admin.firestore().collection('configurations').get()
.then(documents =>
documents.forEach((document) =>
require('fs').writeFile(`${require('../src/utils').baseDir}/config/${document.id}.json`, JSON.stringify(document.data()), (error) =>
error ? console.error(error) : console.log(`Configuration file ${document.id}.json has been created!`))));