Skip to content

Instantly share code, notes, and snippets.

@mosheeshel
mosheeshel / AWS CLI Commands for localstack
Created July 30, 2023 11:53
Some cheat commands to easily view AWS status on localstack container
Localstack docker commands (rentblocks)
# Create fifo queue (note the `.fifo` and special attributes)
aws --endpoint-url=http://127.0.0.1:4566/ --region=us-east-1 sqs create-queue --queue-name TxMgrTransferRequest.fifo --attributes FifoQueue=true,MessageRetentionPeriod=1209600,ContentBasedDeduplication=false
# Create regular sqs queue
aws --endpoint-url=http://127.0.0.1:4566/ --region=us-east-1 sqs create-queue --queue-name TxMgrTransferRequest
# send message to regular code
@mosheeshel
mosheeshel / count-loc.sh
Created November 25, 2021 12:38
Count lines of code in a project, and respect **.gitignore** contents
docker run -v $PWD:/data mribeiro/cloc --exclude-dir=$(tr '\n' ',' < .gitignore) .
@mosheeshel
mosheeshel / cuda-test.py
Last active November 30, 2021 10:01
CUDA test script, verify there is working GPUs detected, by loading CUDA and training a tiny model
print("\nChecking CUDA with pyTorch\n")
import torch
import torch.nn as nn
dev = torch.device("cuda") if torch.cuda.is_available() else False
if not dev:
print("CUDA is not availale")
raise SystemExit(1)
t1 = torch.randn(1,2)
t2 = torch.randn(1,2).to(dev)
@mosheeshel
mosheeshel / create_branch.sh
Last active November 1, 2021 14:15
Small script to improve git branch creation flow for users
create_branch() {
local ORIGIN_BRANCH="origin/main"
if [ -z "$1" ] ; then
echo "branch name is required"
else
if [ ! -z "$2" ] ; then
local ORIGIN_BRANCH="$2"
fi
git checkout -b $1 $ORIGIN_BRANCH
git push -u origin $1:$1
@mosheeshel
mosheeshel / gist:97b2874f169690d5ddb076e1782055e3
Created October 20, 2021 14:38
A thought about a model for a Feature Flag system (really basic)
erDiagram
Project ||..|{ Environment :has
Project ||..|{ FeatureFlag :has
Environment ||..|{ Segment :has
Environment ||..|{ EnvironmentFeatureFlag : has
FeatureFlag ||..|{ EnvironmentFeatureFlag : has
EnvironmentFeatureFlag ||..|{ UserTargeting : has
Segment ||..|{ UserTargeting : has
Audit
Workflow
@mosheeshel
mosheeshel / toggle sequence.md
Created July 15, 2021 12:30
Mermaid powered Sequence Diagram

sequenceDiagram autonumber

ToggleSDK->>+ToggleMicroservice: Get Features
ToggleMicroservice-->>-ToggleSDK: Features
ToggleSDK->>LocalToggleStore: Save features to local storage


par getting toggle values

ToggleSDK->>+LocalToggleStore: Get FeatureToggle value

@mosheeshel
mosheeshel / LaunchdarlyUserSegmentAPI.java
Last active May 25, 2021 11:36
LaunchDarkly, Create and Add UserSegmentRules with the Java API based on examples given here
package com.moshe.ldclient;
import com.launchdarkly.api.ApiClient;
import com.launchdarkly.api.ApiException;
import com.launchdarkly.api.Configuration;
import com.launchdarkly.api.api.UserSegmentsApi;
import com.launchdarkly.api.auth.ApiKeyAuth;
import com.launchdarkly.api.model.*;
import com.launchdarkly.sdk.LDUser;
import com.launchdarkly.sdk.server.LDClient;
package com.kenshoo.teddy.infra;
import com.google.inject.Singleton;
import io.honeycomb.libhoney.Event;
import io.honeycomb.libhoney.HoneyClient;
import io.honeycomb.libhoney.builders.HoneyClientBuilder;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.trace.SpanId;
@mosheeshel
mosheeshel / gist:b1317e32ed33b0205be9ec4b6d79f804
Last active August 12, 2019 19:44
Quick bash script to start a new GIT branch from master or from any other existing branch
create_branch() {
local ORIGIN_BRANCH="origin/master"
if [ -z "$1" ] ; then
echo "branch name is required"
else
if [ ! -z "$2" ] ; then
local ORIGIN_BRANCH="$2"
fi
git checkout -b $1 $ORIGIN_BRANCH
git push -u origin $1:$1
@mosheeshel
mosheeshel / gist:7560362c68ac32b1b0b9d74de892b98e
Last active March 8, 2019 19:32
Create AdInsights Report from Facebook and download it into TSV (customize for different stuff easily)
import time, datetime
import csv
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.adobjects.adreportrun import AdReportRun
from facebook_business.adobjects.campaign import Campaign
import boto3