Skip to content

Instantly share code, notes, and snippets.

View elfenlaid's full-sized avatar
🐧
Slow Distillation ⚗️💭

Egor Mihnevich elfenlaid

🐧
Slow Distillation ⚗️💭
View GitHub Profile
defmodule EctoMigrationTest do
use ExUnit.Case
def rollback, do: Mix.Shell.IO.cmd("MIX_ENV=test mix ecto.rollback --all")
def migrate, do: Mix.Shell.IO.cmd("MIX_ENV=test mix ecto.migrate")
test "test rollback and migration" do
assert 0 == rollback()
assert 0 == migrate()
@elfenlaid
elfenlaid / CoreFoundation+PointerArguments.swift
Last active January 6, 2021 06:55
Calling Core Foundation functions with pointer arguments
let pixelBufferPool: CVPixelBufferPool = // ...
unsafe_pointer: do {
let pixelBufferPointer = UnsafeMutablePointer<CVPixelBuffer?>.allocate(capacity: 1)
defer {
pixelBufferPointer.deinitialize(count: 1)
pixelBufferPointer.deallocate()
}
import Foundation
let stmt: NSString = "Actionable emptiness"
let options: NSLinguisticTagger.Options = [.omitWhitespace, .omitPunctuation, .omitOther]
let stringRange = NSMakeRange(0, stmt.length)
let languageMap = ["Latn":["en"]]
stmt.enumerateLinguisticTags(in: stringRange, scheme: NSLinguisticTagScheme.lemma, options: options, orthography: nil) { tag, _, _, _ in
print(tag?.rawValue)
}
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@elfenlaid
elfenlaid / mraid_tags.js
Created May 6, 2020 08:25
MRAID simple example
<script type="text/javascript">
function doReadyCheck() {
if (mraid.getState() == 'loading') {
//Wait until mraid library is ready and loaded so listen for ready event
mraid.addEventListener("ready", mraidIsReady);
}
else {
showMyAd();
}
}
// Place your key bindings in this file to overwrite the defaults
[{
"key": "shift+ctrl+p",
"command": "cursorUpSelect",
"when": "editorTextFocus"
},
{
"key": "shift+ctrl+f",
"command": "cursorRightSelect",
"when": "editorTextFocus"
@elfenlaid
elfenlaid / test.json
Last active February 8, 2019 20:28
vscode elixir test setup
{
"version": "2.0.0",
"tasks": [
{
"label": "mix test all",
"type": "shell",
"command": "mix",
"args": ["test", "--color", "--trace"],
"options": {
"cwd": "${workspaceRoot}",
git config --global alias.trim '!f() { git branch | grep -v "\*" | xargs -n 1 git branch -D; }; f'
@elfenlaid
elfenlaid / xcodebuild flags.md
Created December 20, 2016 14:12 — forked from mtauraso/xcodebuild flags.md
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.

@elfenlaid
elfenlaid / xcodebuild flags.md
Created December 20, 2016 14:12 — forked from mtauraso/xcodebuild flags.md
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.