Skip to content

Instantly share code, notes, and snippets.

@stephanos
stephanos / script.py
Created December 16, 2023 00:39
switch-api-branch script
#!/usr/bin/env python3
"""
First, you'll need the following repos checked out side by side:
src (name doesn't matter)
|-- api https://github.com/temporalio/api/
|-- api-go https://github.com/temporalio/api-go/
|-- sdk-go https://github.com/temporalio/sdk-go/
\-- temporal https://github.com/temporalio/temporal/
let mut component = Component::new();
component.section(&ModuleSection(&module));
let mut names = ComponentNameSection::new();
let mut func_names = NameMap::new();
func_names.append(0, "main");
names.core_funcs(&func_names);
names.funcs(&func_names);
let mut instance_names = NameMap::new();
instance_names.append(0, "main");
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stephanos
stephanos / after.ex
Last active December 11, 2020 19:06
defmodule Auth do
## IMPERATIVE SHELL
def login(email, input_password) do
with {:ok, user} <- UserRepo.find_by_email(email),
{:allowed, true} <- {:allowed, is_allowed(user, input_password)} do
UserRepo.update_last_login_date(user, DateTime.utc_now())
{:ok, user}
else
_ -> :error
end
defmodule Auth do
def login(email, password) do
case UserRepo.find_by_email(email) do
{:ok, user} ->
password_hash = BCrypt.hash(password)
cond do
user.hash != hash -> :error
user.active == false -> :error
user.deleted_at != nil -> :error
true ->
@stephanos
stephanos / gae.ex
Last active November 24, 2019 23:19
using Google Cloud's Stackdriver Logging API on App Engine with Elixir
defmodule GoogleAppEngine do
def google_cloud_project() do
System.get_env("GCLOUD_PROJECT",
System.fetch_env!("GOOGLE_CLOUD_PROJECT"))
end
def google_app_engine_service() do
System.fetch_env!("GAE_SERVICE")
end
#!/usr/bin/env bash
weeks=90
echo "all"
echo "java"
echo "groovy"
echo "js"
echo "specs"
@stephanos
stephanos / stopwords.txt
Created March 19, 2016 17:14
slack wordcloud (de)
ab
bei
da
deshalb
ein
für
haben
hier
ich
ja
@stephanos
stephanos / install-app-engine-sdk
Last active January 15, 2017 08:33
Download current Go App Engine SDK
#!/bin/bash
VERSION_URL="https://appengine.google.com/api/updatecheck"
VERSION=$(echo $(curl ${VERSION_URL}) | sed -E 's/release: \"(.+)\"(.*)/\1/g')
ARCH="386"
if [[ `uname -a` == *x86_64* ]]
then
ARCH="amd64"
fi
def IDEA_MODULE_NAME = 'mymodule'
def IDEA_ARTIFACT_NAME = 'myproject'
def artifactManager = xmlFile.asNode().component.find { it.@name == 'ArtifactManager' } as Node
if (artifactManager) {
Node artifact = artifactManager.artifact.find { it.@type == 'exploded-war' }
if (artifact)
artifactManager.remove(artifact)
} else {
artifactManager = xmlFile.asNode().appendNode('component', [name: 'ArtifactManager']);