Skip to content

Instantly share code, notes, and snippets.

View alexwal's full-sized avatar
❤️
🧡💛💚💙💜🖤

Alexander Walczak alexwal

❤️
🧡💛💚💙💜🖤
  • New York, NY
View GitHub Profile
@IanKeen
IanKeen / Codable+InnerArrays.swift
Last active March 3, 2022 00:57
Skipping nested wrappers in json w/ Codable
extension KeyedDecodingContainer {
func decode<T: Decodable, Inner: CodingKey>(_ type: T.Type, forKey key: KeyedDecodingContainer.Key, innerKey: Inner) throws -> [T] {
var array = try nestedUnkeyedContainer(forKey: key)
var items: [T] = []
while !array.isAtEnd {
let container = try array.nestedContainer(keyedBy: Inner.self)
let item = try container.decode(T.self, forKey: innerKey)
items.append(item)
}
@danijar
danijar / share_variables_decorator.py
Last active November 20, 2021 17:21
TensorFlow decorator to share variables between calls. Works for both functions and methods.
import functools
import tensorflow as tf
class share_variables(object):
def __init__(self, callable_):
self._callable = callable_
self._wrappers = {}
@alexwal
alexwal / cluster_barrier_for_tensorflow.py
Last active March 27, 2020 07:13 — forked from yaroslavvb/simple_barrier.py
Example of using shared counters to implement Barrier primitive
'''
Alex Walczak, 2017
Example of barrier implementation using TensorFlow shared variables
across a multi-machine cluster.
All workers synchronize on the barrier, copy global parameters to local versions,
and increment the global parameter variable asynchronously.
On each worker run:

Disable Device Enrollment Notification on Mac.md

Restart the Mac in Recovery Mode by holding Comment-R during restart

Open Terminal in the recovery screen and type

csrutil disable
import Foundation
import Gridicons
import UIKit
import WebKit
class WebViewController: UIViewController {
let webView = WKWebView()
let progressView = WebProgressView()
let toolbar = UIToolbar()
let titleView = NavigationTitleView()
@hackjutsu
hackjutsu / upstream.md
Last active December 11, 2023 07:44
[set upstream] What does '--set-upstream' do? #tags: git
git branch --set-upstream-to <remote-branch>
# example
git branch --set-upstream-to origin feature-branch

# show up which remote branch a local branch is tracking
git branch -vv

sets the default remote branch for the current local branch.

@fertapric
fertapric / ecs-run
Last active December 10, 2018 05:00
Script to run a Docker container with the same configuration as the ECS service: environment variables and Docker image. It uses ecs-env: https://gist.github.com/fertapric/4ae3a1209e7118c275821ce35512daec
$ ecs-run
Run a Docker container with the same configuration as an ECS service.
It uses the same image and environment variables of the ECS task definition.
Supported AWS CLI environment variables:
- AWS_ACCESS_KEY_ID: AWS access key.
- AWS_SECRET_ACCESS_KEY: AWS secret key.
- AWS_SESSION_TOKEN: session token.
- AWS_DEFAULT_REGION: AWS region.
@johndelong
johndelong / ViewController.swift
Last active March 28, 2021 00:26
Infinite Scrolling Final
//
// ViewController.swift
// Example
//
// Created by John DeLong on 5/11/16.
// Copyright © 2016 delong. All rights reserved.
//
import UIKit
@trestletech
trestletech / instance-types.sh
Created June 15, 2016 16:41
Get all EC2 Instance Types in All Availability Zones
#!/bin/bash
echo "Getting list of Availability Zones"
all_regions=$(aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]' | sort)
all_az=()
while read -r region; do
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward