This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Random background colours with appropriate text colour.</title> | |
<script type="text/javascript"> | |
function randomColor(){ | |
return '#'+(function lol(m,s,c){return s[m.floor(m.random() * s.length)] + (c && lol(m,s,c-1));})(Math,'0123456789ABCDEF',4); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import SimpleHTTPServer | |
# Simple web server with caching disabled (useful for development) | |
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self) | |
def send_my_headers(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __image main(__image src) { | |
return fish2sphere.apply(src.definition, null, src); | |
} | |
//////// | |
kernel vec4 fish2sphere(sampler src) | |
{ | |
vec2 pfish; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fisheye to spherical conversion | |
// Assumes the fisheye image is square, centered, and the circle fills the image. | |
// Output (spherical) image should have 2:1 aspect. | |
// Strange (but helpful) that atan() == atan2(), normally they are different. | |
kernel vec4 fish2sphere(sampler src) | |
{ | |
vec2 pfish; | |
float theta,phi,r; | |
vec3 psph; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Custom Post Types | |
* Description: Custom post types plugin. | |
* Plugin URI: http://kosso.co.uk | |
* Version: 1.0.0 | |
* Author: Kosso | |
* Author URI: http://kosso.co.uk | |
* License: Free | |
* Network: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Custom Post Types Example | |
* Description: An example plugin to create custom post types with custom taxonomies and custom meta fields, including exposing to the REST API. | |
* Plugin URI: http://kosso.co.uk | |
* Version: 1.0.0 | |
* Author: Kosso | |
* Author URI: http://kosso.co.uk | |
* License: GPLv2 | |
* Network: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LetsEncrypt Autorenewal | |
----------------------- | |
Let's say you created and installed an Apache certificate with: | |
./certbot-auto -n --apache --agree-tos -m [email protected] -d yourdomain.com -d www.yourdomain.com | |
Create a file called 'letsencrypt-autorenew' (or anything really) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add before the sendPickerSuccess in MediaModule.m | |
// ~ line 2104 | |
// Provides event.gifmedia with the success event if a GIF is picked as a TiBlob. | |
// If so, the event.media is the first frame as a PNG. | |
// Kosso | |
// See if it's a GIF. Use the referenceURL | |
NSURL *referenceURL = [editingInfo objectForKey:UIImagePickerControllerReferenceURL]; | |
NSString *_mime = [Mimetypes mimeTypeForExtension:[referenceURL path]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SVG Fixer | |
* | |
* Fixes references to inline SVG elements when the <base> tag is in use. | |
* Firefox won't display SVG icons referenced with | |
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page. | |
* | |
* More info: | |
* - http://stackoverflow.com/a/18265336/796152 | |
* - http://www.w3.org/TR/SVG/linking.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates our main root window. Fullscreen all the way! | |
var win = require('/ui/common/window_home').createWindow(); | |
if(Ti.Platform.osname==='android'){ | |
// This Theme makes sure the windows are full screen and buttons aren't always in caps. | |
// mytheme.xml lives in /platform/android/res/values - see below. | |
win.open({theme: "MyAmazingTheme"}); | |
} else { | |
var rootNavWin = Titanium.UI.iOS.createNavigationWindow({ |