Skip to content

Instantly share code, notes, and snippets.

{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "API",
"description": "API"
},
"schemes": [
"http"
],
import Foundation
func testFunction(completion: () -> ()) {
dispatch_async(dispatch_get_main_queue()) {
completion()
}
}
func testSemaphore() {
let semaphore = dispatch_semaphore_create(0)
@mxl
mxl / PageSplitter.java
Last active December 29, 2015 09:09
Class for splitting styled text to pages.
package com.codeoverdrive.util;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.style.StyleSpan;
import java.util.ArrayList;
import java.util.List;
@mxl
mxl / photoshop-export-layers-ipad.jsx
Last active January 1, 2016 22:39
Exports first-level layers and layer groups to png images for iPad and iPad with Retina display.
#target photoshop
function main(){
function scanLayers(el, path, isRetina) {
new Folder(path).create();
// process layer sets (groups)
for(var i = 0; i < el.layerSets.length; i++){
var layer = el.layerSets[i];
if (!layer.visible)
@mxl
mxl / photoshop-export-layers-iphone.jsx
Last active January 1, 2016 22:39
Exports first-level layers and layer groups to png images for iPhone and iPhone with Retina display.
#target photoshop
function main(){
function scanLayers(el, path, isRetina) {
new Folder(path).create();
// process layer sets (groups)
for(var i = 0; i < el.layerSets.length; i++){
var layer = el.layerSets[i];
if (!layer.visible)
@mxl
mxl / photoshop-export-layers-android.jsx
Last active January 1, 2016 22:39
Exports first-level layers and layer groups to png images for Android (ldpi, mdpi, hdpi, xhdpi).
#target photoshop
function main(){
if(!documents.length)
return;
// suppress all dialogs
app.displayDialogs = DialogModes.NO;
var mainDoc = app.activeDocument;
var docFullName = mainDoc.fullName;
import UIKit
import XCPlayground
enum UIImageAlignment {
case Center, Left, Top, Right, Bottom, TopLeft, BottomRight, BottomLeft, TopRight
}
enum UIImageScaleMode {
case Fill,
AspectFill,
#!/usr/bin/env bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_obs_testfile}
TEST_FILE_EXISTS=0
if [ -e "$TEST_FILE" ]; then TEST_FILE_EXISTS=1; fi
TEST_FILE_SIZE=134217728
#!/usr/bin/env bash
set -e
PATTERN=$1
COUNT=0
for RULE in $(sudo ufw status numbered | (grep $PATTERN | awk -F"[][]" '{print $2}')); do
sudo ufw --force delete $((RULE-COUNT))
((COUNT=COUNT+1))
done
@mxl
mxl / log_out.svg
Last active January 12, 2021 18:43
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.