layout: post title: "ReactiveCocoa Unit Testing Tips" date: 2013-09-22 20:45 comments: true categories:
- Testing
- iOS
- Patterns
- Xcode
-- AppleScript -- | |
-- This example is meant as a simple starting point to show how to get the information in the simplest available way. | |
-- Keep in mind that when asking for a `return` after another, only the first one will be output. | |
-- This method is as good as its JXA counterpart. | |
-- Webkit variants include "Safari", "Webkit", "Orion". | |
-- Specific editions are valid, including "Safari Technology Preview". | |
-- "Safari" Example: | |
tell application "Safari" to return name of front document |
@implementation AppDelegate | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
NSNotificationCenter *nc = [[NSWorkspace sharedWorkspace] notificationCenter]; | |
[nc addObserver:self | |
selector:@selector(spaceChanged:) | |
name:NSWorkspaceActiveSpaceDidChangeNotification | |
object:[NSWorkspace sharedWorkspace]]; |
layout: post title: "ReactiveCocoa Unit Testing Tips" date: 2013-09-22 20:45 comments: true categories:
let bitmapBuffer = UnsafePointer<UInt8>.alloc(Int(height * width * 4)) | |
let pixelNumber = (x * 4) + (y * width * 4) | |
bitmapBuffer[pixelNumber + 3] = 255 // Alpha | |
bitmapBuffer[pixelNumber + 2] = redValue | |
bitmapBuffer[pixelNumber + 1] = greenValue | |
bitmapBuffer[pixelNumber + 0] = blueValue |
# updates an environment variable of a running process (needs sudo) | |
# example: sudo export_pid <variable=value> <pid> | |
export_process(){ | |
script=/tmp/.gdb.$2 | |
echo -e "attach $2\ncall putenv (\"$1\")\ndetach\n" > $script | |
gdb -q -batch -x $script &>/dev/null | |
rm $script | |
} |
What xcode project/workspace file we're using. If you specify a project on the command-line and that project has an associated workspace, the project is still aware of its existence within the workspace. As an example, worspace level schemes will be available to xcodebuild even if you specify a project on the command line.
Specify the scheme to use for build. Schemes specify multiple build/test targets along with environment args and command line parameters. Schemes must be marked "shared" in the xcode UI in order to be available to xcodebuild. For any particular build/test action there is a default configuration when you use a scheme from the Xcode UI.
# Keep in mind that when asking for a `return` after another, only the first one will be output. | |
# This example is meant as a simple starting point, to show how to get the information in the simplest available way. | |
# Google Chrome | |
tell application "Google Chrome" to return URL of active tab of front window | |
tell application "Google Chrome" to return title of active tab of front window | |
# Google Chrome Canary | |
tell application "Google Chrome Canary" to return URL of active tab of front window | |
tell application "Google Chrome Canary" to return title of active tab of front window | |
# Chromium |
# lazyload nvm | |
# all props goes to http://broken-by.me/lazy-load-nvm/ | |
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/ | |
lazynvm() { | |
unset -f nvm node npm npx | |
export NVM_DIR=~/.nvm | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
if [ -f "$NVM_DIR/bash_completion" ]; then | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion |
from tf_logger import TFLogger | |
""" Example of using TFLogger to save train & dev statistics. To visualize | |
in tensorboard simply do: | |
tensorboard --logdir /path/to/summaries | |
This code does depend on Tensorflow, but does not require that your model | |
is built using Tensorflow. For instance, could build a model in Chainer, then |
import torch | |
import numpy as np | |
import pickle | |
f = open('/home/eriba/software/pytorch/examples-edgarriba/triplet/nan_test.pkl', 'rb') | |
data = pickle.load(f) | |
a = torch.from_numpy(data['a']).cuda() |