Skip to content

Instantly share code, notes, and snippets.

View tmdvs's full-sized avatar
:shipit:
making things and breaking things

Tim Davies tmdvs

:shipit:
making things and breaking things
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tmdvs on github.
  • I am tmdvs (https://keybase.io/tmdvs) on keybase.
  • I have a public key whose fingerprint is 1DB3 BBAF C199 5A3A 4EEF C6AC FC75 986C 1B3F 3CE2

To claim this, I am signing this object:

@tmdvs
tmdvs / 3.0 Tethering
Created February 1, 2017 14:27 — forked from ars/3.0 Tethering
YES CHRIS, I WROTE THIS UP -- ERICA (erica.sadun@arstechnica.com)
p.s. Follow me on twitter: @ericasadun
-------------
US AT&T Customers: I don't have specific details on adding tethering to your account but just give AT&T a call. They'll help with the billing.
Note: UK People start here: http://twitter.com/timmeh/status/1351833678
Note: US People look here: http://tinyurl.com/cstrqx (New version by Michael Johnston of iPhone Alley)
Over Bluetooth: http://www.joachimbean.com/Computer_Inventory/News/Entries/2009/3/19_Tethering_on_iPhone_OS_3.0_over_AT&T.html
@tmdvs
tmdvs / bubble.swift
Last active July 4, 2022 19:04
Bubble sort in Swift
// An Example of a bubble sort algorithm in Swift
//
// Essentialy this algorithm will loop through the values up to
// the index where we last did a sort (everything above is already in order/sorted)
// comparing a one value to the value before it. If the value before it is higher,
// swap them, and note the highest swap index. On the next iteration of the loop we
// only need to go as high as the previous swap.
import Foundation
@tmdvs
tmdvs / UIBlockSwitch.m
Last active January 26, 2020 02:31
UISwitch with block handler
@interface UIBlockSwitch : UISwitch {
ActionBlock _actionBlock;
}
-(void) handleControlEvent:(UIControlEvents)event
withBlock:(ActionBlock) action;
@end
@implementation UIBlockSwitch
{% if item.modifiers %}
<ul class="modifiers">
{% for value in item.modifiers %}
<li><strong>{{ value.meta.name }}:</strong> {{ value.value }}</li>
{% endfor %}
</ul>
{% endif %}
/**
* Handle the dynamic retrieval of attributes and associations.
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
// Lets check if the model has a function for this first
if(method_exists($this, $key))
class User extends Base
{
public static $table = 'users';
public static $rules = array('email' => 'required|email|unique:users','password' => 'required',);
}
Handlebars.registerHelper('set', function(name, value) {
Handlebars.registerHelper(name, function() {
return value;
});
});
/* usage */
{{ set "foo" "bar" }}
int64_t delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
<#code to be executed on the main queue after delay#>
});
// Do something in the background and then when done call something on the main thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
@tmdvs
tmdvs / null
Created September 26, 2012 16:11
<?PHP
function sortPins (&$array, $key) {
$sorterArray = array();
$ret=array();
reset($array);
foreach ($array as $ii => $va)
$sorterArray[$ii]=$va[$key];