Skip to content

Instantly share code, notes, and snippets.

View akkyie's full-sized avatar

Akio Yasui akkyie

View GitHub Profile
extension UInt {
func withZeroes(digits: UInt) -> String {
guard digits > 1 && Decimal(self) < pow(10, Int(digits - 1)) else {
return String(describing: self)
}
return "0" + self.withZeroes(digits: digits - 1)
}
}
<?php
$posts_query = new WP_Query(['posts_per_page' => -1]);
$images_query = new WP_Query([
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
]);
import Foundation
extension NSObjectProtocol {
func configure(closure: (Self) -> ()) -> Self {
closure(self)
return self
}
}
import Foundation
extension Array {
func random() -> Element {
return self[Int(arc4random_uniform(UInt32(self.count)))]
}
}
//
// main.c
// (c) 2016 Akio Yasui
//
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <stdio.h>
@akkyie
akkyie / Graph.swift
Created November 18, 2015 07:54
Graph.swift
//
// Graph.swift
// CoreMesh
//
// Created by Akio Yasui on 10/24/15.
// Copyright © 2015 Akio Yasui. All rights reserved.
//
import Foundation