Skip to content

Instantly share code, notes, and snippets.

@marcboquet
marcboquet / gist:340c240c50aed6c71a1e
Created August 8, 2014 15:37
Create empty Swift playground files
#! /usr/bin/ruby
require 'pathname'
platform = "iphonesimulator" # or "macosx"
contents_xcplayground = <<XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='1.0' sdk='#{platform}'>
<sections>
<code source-file-name='section-1.swift'/>
</sections>
@walterlua
walterlua / table_copy.lua
Created May 18, 2011 07:50
Implementation of JavaScript array.concat() in Lua. Also, adds the function to Lua's table library
-- table.copy( array, ... ) returns a shallow copy of array.
-- A variable number of additional arrays can be passed in as
-- optional arguments. If an array has a hole (a nil entry),
-- copying in a given source array stops at the last consecutive
-- item prior to the hole.
--
-- Note: In Lua, the function table.concat() is equivalent
-- to JavaScript's array.join(). Hence, the following function
-- is called copy().
table.copy = function( t, ... )
@uchida
uchida / dlclt.py
Created August 31, 2012 22:22
CUI Downloader of Command Line Tools for Xcode
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# CUI Downloader of "Command Line Tools for Xcode"
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import sys, os
import urllib, urllib2, cookielib
from getpass import getpass
from HTMLParser import HTMLParser
@steventroughtonsmith
steventroughtonsmith / gist:6763213
Created September 30, 2013 12:39
Non-opaque application windows in iOS 7, with optional blur. Shows the user's wallpaper under the app, with Parallax if supported.
typedef enum _UIBackgroundStyle {
UIBackgroundStyleDefault,
UIBackgroundStyleTransparent,
UIBackgroundStyleLightBlur,
UIBackgroundStyleDarkBlur,
UIBackgroundStyleDarkTranslucent
} UIBackgroundStyle;
@interface UIApplication (UIBackgroundStyle)
-(void)_setBackgroundStyle:(UIBackgroundStyle)style;
//
// Library.swift
// LabelLayout
//
// Created by Chris Eidhof on 09.09.18.
// Copyright © 2018 objc.io. All rights reserved.
//
import UIKit
@carsonmcdonald
carsonmcdonald / swift-amzn-ami.sh
Created January 11, 2016 04:35
Build Swift on an Amazon Linux AMI
#
# Notes:
#
# I used the following AMI:
# "Amazon Linux AMI 2015.09.1 (HVM), SSD Volume Type - ami-60b6c60a"
# Running on AMI: amzn-ami-hvm-2015.09.1.x86_64-gp2 (ami-60b6c60a)
#
# You probably want to use an instance type with a large amount of memory. My first
# attempt was with a c4.2xlarge but it rant out of memory without using -j option to
# limit the parallel build.
@mislav
mislav / easy_way.rb
Last active May 20, 2020 13:48
RESOLVE SHORT URLS before storing. Short URLs are for microblogging; you should never actually keep them around.
require 'net/http'
# WARNING do not use this; it works but is very limited
def resolve url
res = Net::HTTP.get_response URI(url)
if res.code == '301' then res['location']
else url.to_s
end
end
@norio-nomura
norio-nomura / AppDelegate.m
Created October 4, 2012 02:14
How to call objc_msgSendSuper()
//
// AppDelegate.m
// CallSuperMethod
//
#import <objc/objc-runtime.h>
#import "AppDelegate.h"
@interface Superclass : NSObject
- (NSString*)a;
@shaps80
shaps80 / cURL+Request.swift
Last active December 23, 2023 17:43
Generates a cURL command representation of a URLRequest in Swift.
import Foundation
extension URLRequest {
/**
Returns a cURL command representation of this URL request.
*/
public var curlString: String {
guard let url = url else { return "" }
var baseCommand = #"curl "\#(url.absoluteString)""#
@pfig
pfig / mkfavicon.sh
Created February 12, 2012 12:01
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png