Skip to content

Instantly share code, notes, and snippets.

View andrewschreiber's full-sized avatar
🎯
Focusing

Andrew Schreiber andrewschreiber

🎯
Focusing
View GitHub Profile
@vitorgalvao
vitorgalvao / Get Title and URL.applescript
Last active June 14, 2024 05:12
AppleScript and JavaScript for Automation to get frontmost tab’s url and title of various browsers.
-- 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
@tomkrcha
tomkrcha / gist:9009845
Created February 14, 2014 21:36
Detect if Mac OSX space changed in cocoa - NSWorkspaceActiveSpaceDidChangeNotification change / event / notification
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSNotificationCenter *nc = [[NSWorkspace sharedWorkspace] notificationCenter];
[nc addObserver:self
selector:@selector(spaceChanged:)
name:NSWorkspaceActiveSpaceDidChangeNotification
object:[NSWorkspace sharedWorkspace]];
@lawrencelomax
lawrencelomax / rac_testing.md
Created April 30, 2014 15:38
RAC Testing abortive blogpost

layout: post title: "ReactiveCocoa Unit Testing Tips" date: 2013-09-22 20:45 comments: true categories:

  • Testing
  • iOS
  • Patterns
  • Xcode
@rothomp3
rothomp3 / swift-buffer-example.swift
Last active January 1, 2020 17:09
Swift example of writing to memory buffer
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
@coderofsalvation
coderofsalvation / export_process
Last active February 22, 2022 15:38
updates an environment variable of a running process
# 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
}
@mtauraso
mtauraso / xcodebuild flags.md
Last active November 15, 2023 15:44
Xcodebuild flags in CI

Xcodebuild flag reference for CI:

Required flags:

-project OR -workspace

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.

-scheme

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.

@dongyuwei
dongyuwei / get_title_and_url.applescript
Last active June 30, 2024 09:19 — forked from vitorgalvao/Get Title and URL.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# 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
@mrdrozdov
mrdrozdov / example.py
Last active December 28, 2018 22:10
Logging in Tensorflow
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()