Copy and Paste or create a code snippet in xcode
Access snippets in Xcode with ⇧⌘L
/*!
@class <#Class Name#>
@brief <#Quick Description#>
@discussion <#Talk about what this does in more detail#>
@namespace <#What is the Namespace if any#>| # declares an array with the emojis we want to support | |
| EMOJIS=("🐑" "🦔" "🐈" "🦆" "🐓") | |
| # function that selects and return a random element from the EMOJIS set | |
| RANDOM_EMOJI() { | |
| SELECTED_EMOJI=${EMOJIS[$RANDOM % ${#EMOJIS[@]}]}; | |
| echo $SELECTED_EMOJI; | |
| } | |
| # declare the terminal prompt format |
| #include <ApplicationServices/ApplicationServices.h> | |
| #include <iostream> | |
| #include <string> | |
| ///print out location in a nice way to std cout | |
| void fancyPrintLocation(CGPoint location); | |
| /// This callback will be invoked every time the mouse moves. | |
| CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, | |
| CGEventRef event, void *refcon) |
| function out = autocorrolate(signal) | |
| % AUTOCORROLATE Multiply a signal by itself over a moving delay window. | |
| % Max delay will be equal to the length of the signal | |
| % Y = AUTOCORROLATE(x) returns auto correlation of x | |
| % | |
| N = length(signal); | |
| out = zeros(size(signal)); | |
| for l = 1:N - 1 | |
| for n = l+1:(N) | |
| out(l) = out(l) + (signal(n)*signal(n-l)); |
Copy and Paste or create a code snippet in xcode
Access snippets in Xcode with ⇧⌘L
/*!
@class <#Class Name#>
@brief <#Quick Description#>
@discussion <#Talk about what this does in more detail#>
@namespace <#What is the Namespace if any#>| //------------------------------------------------------------------------------ | |
| import AVFoundation | |
| //------------------------------------------------------------------------------ | |
| var secondsOfAudio:Float = 0.5; // or var secondsOfAudio:Float = Float(CommandLine.arguments[1])!; | |
| //------------------------------------------------------------------------------ | |
| var ae:AVAudioEngine? = AVAudioEngine() | |
| var player:AVAudioPlayerNode? = AVAudioPlayerNode() | |
| var mixer:AVAudioMixerNode? = ae?.mainMixerNode; | |
| //------------------------------------------------------------------------------ | |
| let sr:Float = Float((mixer?.outputFormat(forBus: 0).sampleRate)!) |
| import csv, os | |
| def add_csv_column(filename: str, column_name: str, data: list) -> None: | |
| """ | |
| Add a column of data to an existing csv file | |
| pads with empty string if data size does not match target csv | |
| :param filename: path to csv file |
Create a Swift Command Line Tool in Xcode. You can then copy and paste the below code into the .swift and .metal files respectively
main.swift
| #include <iostream> | |
| #include <memory> | |
| void setPtr (int *a) | |
| { | |
| std::cout << *a << '\n'; | |
| } | |
| int main(int argc, const char * argv[]) | |
| { |
# verbose, but customisable
ffmpeg -i VIDEO.EXTENSION -vf "fps=10,scale=680:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 OUT.gif
# gritty, but portable