Skip to content

Instantly share code, notes, and snippets.

@cockscomb
cockscomb / swift-format.rb
Created December 18, 2019 22:17
Homebrew Formula of apple/swift-format
class SwiftFormat < Formula
desc "Formatting technology for Swift source code"
homepage "https://github.com/apple/swift-format"
url "https://github.com/apple/swift-format.git", :branch => "swift-5.1-branch"
head "https://github.com/apple/swift-format.git"
depends_on :xcode => ["11.0", :build]
def install
system "swift", "build", "--configuration", "release",
diff --git a/SelfSizingAutoLayoutCell/SelfSizingAutoLayoutCell.m b/SelfSizingAutoLayoutCell/SelfSizingAutoLayoutCell.m
index 0acbbe5..db816f3 100644
--- a/SelfSizingAutoLayoutCell/SelfSizingAutoLayoutCell.m
+++ b/SelfSizingAutoLayoutCell/SelfSizingAutoLayoutCell.m
@@ -47,7 +47,9 @@ NS_ASSUME_NONNULL_BEGIN
[constraints addObject:[autolayoutView.topAnchor constraintEqualToAnchor:self.contentView.topAnchor constant:10.0]];
[constraints addObject:[autolayoutView.leadingAnchor constraintEqualToAnchor:self.contentView.leadingAnchor constant:10.0]];
[constraints addObject:[self.contentView.trailingAnchor constraintEqualToAnchor:autolayoutView.trailingAnchor constant:10.0]];
- [constraints addObject:[self.contentView.bottomAnchor constraintEqualToAnchor:autolayoutView.bottomAnchor constant:10.0]];
+ NSLayoutConstraint *constraint = [self.contentView.bottomAnchor constraintEqualToAnchor:autolayoutView.bottomAnchor constant:10.0];

How to use

var stdAlert = StdAlert(self)
print("Alert Title\nAlert Body", &stdAlert)

Place this code in your view controller.

@cockscomb
cockscomb / reorder.js
Created November 15, 2014 07:04
本の自炊で間違って逆順にスキャンしてしまったときAcrobatで順番を修正するJavaScript
function reorder()
{
var lastPage = this.numPages - 1;
for (var i = 0; i <= lastPage; ++i) {
this.movePage(0, lastPage - i);
}
}
reorder();
こんにちは
@cockscomb
cockscomb / theta.go
Last active December 28, 2015 07:39
package main
import (
"math"
"code.google.com/p/go-tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for y := range pic {
@cockscomb
cockscomb / remove-empty-glyphs.py
Created April 23, 2013 11:12
Webフォントに使用するフォントから空のグリフを除くためのfontforgeスクリプティングインターフェース用のPythonスクリプト
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import fontforge
import argparse
def remove_empty_glyphs(input, output):
font = fontforge.open(input)
code_points = []
@cockscomb
cockscomb / tags.m
Created December 4, 2012 10:31 — forked from anonymous/Only prints query once
Prints Query 1
NSArray *tags = [all valueForKey:@"tag"];
NSMutableArray *adoptTags = [[NSMutableArray alloc] init];
for (NSString *tagQuery in tags) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"tag CONTAINS[cd] %@", tagQuery];
NSArray *roughArray = [all filteredArrayUsingPredicate:predicate];
NSArray *tagContent = [[NSSet setWithArray:roughArray] allObjects];
[adoptTags addObjectsFromArray:tagContent];
}
NSLog(@"Tags: %@", adoptTags);
@cockscomb
cockscomb / hackerrank.py
Created July 4, 2012 02:04
HackerRank Python Module
#!/usr/bin/env python
import urllib2
import json
import sys
import time
import multiprocessing
from cookielib import CookieJar
from urllib import urlencode
### Other 3rd party functions
#!/usr/bin/env ruby
# coding: utf-8
puts ARGV.join(' ').split(//).collect { |s| 'U+%04X' % s.unpack('U')[0] }.join(' ')